The Simplest Code

Beck describes the simplest code this way, in priority order:

  1. Runs all the tests.
  2. Contains no duplication.
  3. Expresses all the ideas you want to express.
  4. Minimizes number of classes and methods.

(Sometimes he reverses numbers 2 and 3. Interesting thought problem.)

When you are considering YAGNI (YouArentGonnaNeedIt) and DTSTTCPW (DoTheSimplestThingThatCouldPossiblyWork), you must consider these rules. Generating TheSimplestCode is not complete unless you have refactored according to the rules above.

Nearly every objection and concern about YAGNI and DTSTTCPW is about leaving cruft in the code. TheSimplestCode says you must not do that. Defense rests.


>> 4. Minimizes number of classes and methods.

One class with one method? Hmm. It would be very hard to do that, without violating rules 1. and 2. in anything but the simplest case.

How do you define what is minimal?


See also OnceAndOnlyOnce XpSimplicityRules


CategoryExtremeProgramming


EditText of this page (last edited June 15, 2007) or FindPage with title or text search