Hacker News new | past | comments | ask | show | jobs | submit login

Ugly, given that it is an emotional word, applies to any code that you don't like.

WHY do you not like some code? To avoid pointless discussions about taste and gut feelings, I'd bring it down to falsifiable statements.

"This is hard to maintain, for reasons X and Y" is such a statement. As is: "This is hard to test for reason: It needlessly engages in combinatorial explosion" is another.

Yes, you could shorten that to 'ugly'. Good for you.

Nevertheless, I've seen tons of discussions referring to 'ugly' code where the reasons were solid but completely different from maintainability (for example: "It is longer than needed", "It does is not idiomatic for this language"), or even not particularly solid ("It is ugly because it isn't functional", "It is ugly because the style guide says all APIs should always be interfaces", "It is ugly because I see tabs, not spaces").




In a sense those are all finer grained extensions of the same concept: How hard it is to reason about the code. On the highest level are easily quantifiable things like wrapping several error producing segments in a single try / catch block, obscuring the source of an error. Use of interfaces makes documentation and refactoring easy. Then the lowest level stuff is pure style -- much more subjective, but meaningful in a team environment. When people write code in the same style, you spend less time parsing style differences and more times parsing the actual semantics.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: