By equivalence
via equivalence.co.uk
Published: Dec 05 2008 / 15:36
It is known that beautiful code improves readability and therefore makes maintaining such a code base easier. However, time and time again we are confronted with code that is neither elegant nor beautiful. This article attempts to address the latter by describing ways to make your code beautiful.
Comments
je88484 replied ago:
I find the author's first point "Return from if statements as quickly as possible." ironic. For many years, I was told that one should never exit a function other than by completing the last statement in the function. Also one must never use a break to terminate a loop. Only the conditions specified in the loop statement itself should determine when to exit. These practices were widely believed necessary to uphold the principles of structured programming. These beliefs haven't disappeared. My son studied Java in high school less than 5 years ago. His instructor forbade the use of the switch because its usual use requires one to employ a break. It makes me wonder when, exactly, the programming community changed its collective mind on this? What other "truisms" of today (TDD?) will be abandoned in the next 10 years or so?
Voters For This Link (53)
Voters Against This Link (3)