Link Details

Link 139219 thumbnail
User 358503 avatar

By equivalence
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.
  • 53
  • 3
  • 7367
  • 14


Add your comment
User 128441 avatar

je88484 replied ago:

0 votes Vote down Vote up Reply

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?

Add your comment

Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Apache Hadoop
Written by: Piotr Krewski
Featured Refcardz: Top Refcardz:
  1. Play
  2. Akka
  3. Design Patterns
  4. OO JS
  5. Cont. Delivery
  1. Play
  2. Java Performance
  3. Akka
  4. REST
  5. Java