C. Keith Ray

C. Keith Ray writes about and develops software in multiple platforms and languages, including iOS® and Macintosh®.
Keith's Résumé (pdf)

Friday, August 15, 2008

Clean Code

Clean Code (also known as "Simple Code" as defined by Kent Beck) is (paraphrased):
  • Correct: it passes all its tests and its tests are thorough (but not redundant) and correct.

  • Does not contain duplication: Duplicate logic is eliminated and localized in a few places – this may require using functional or object oriented concepts and design patterns. Duplicate data is minimized. Duplicate syntax is also minimized. No redundency.

  • Expresses its concepts: by using good class names, methods names, and other identifiers. Dependencies are expressed in interfaces. Methods and classes are short, readable, and have a single responsibility.

  • Contains no superfluous parts: it does not have dead code, unnecessary parameters, etc. No code left over from features that have been removed. No code for features that haven't been scheduled for implementation.
I find that more explanation is often needed, since some programmers will, for example, point at "expresses its concepts" by saying: this huge function in this huge class perfectly expresses the two dozen actions it performs.

No comments:

Post a Comment