Learning to Ignore Superficially Ugly Code

by buduon 12/13/10, 7:22 PMwith 5 comments
by DanHultonon 12/13/10, 8:20 PM

I'd take the time to make the fix, update the indenting, fix up the inconsistencies, and all that. I know all about the Broken Windows Theory (http://en.wikipedia.org/wiki/Broken_windows_theory), and have seen it in practice in too many places to ignore things like this and let them "slide".

You let one slide, then another, then another still. Eventually, you start getting little mistakes like this everywhere, because all of your code is ugly and difficult to read, and you have built up just mountains of technical debt.

by ihumanableon 12/13/10, 9:32 PM

Having come into possession of some of the ugliest PHP code I've ever seen, I would say it's definitely worthwhile to fix it.

Thousand line files with what appears to be random indentation are a nightmare to work with. Meaningless variable names make it a game of mental gymnastics to figure out what $total = $poster * $gmd / $p->lasty is supposed to be doing.

This is based off my actual real world usage, taking the hour to reformat a multi-thousand line script which has a habit of exposing interesting edge-case bugs ever couple of weeks has probably saved me far more time than it cost.

by mansron 12/13/10, 8:14 PM

I take badly formatted code as a sign of sloppiness on the part of the author, and this usually comes through in more than just the formatting. This saves me the time to actually read the code.

by muyyatinon 12/13/10, 7:28 PM

Usually pretty indentation helps people read and scan the code faster, and using a tool to auto-format the code is a very small time investment that helps save reading time in the long run.