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)

Tuesday, July 29, 2008

Three rules of TDD?

A recent object mentor blog entry said:
We had an interesting result during that class. One group was practicing Bob’s three rules of TDD (paraphrased);
  • Write no production code without failing tests
  • Write only enough test code so that it fails (not compiling is failing)
  • Write only enough production code to get your tests to pass.
But they ended up with a bit of a mess. Following the three rules wasn’t enough. These rules are guiding principles, but those three rules mean nothing if you forget about clean code, refactoring and basic design principles [...]
Maybe the cause of the mess were the rules they used. I remember the rules more like this:
  1. Write enough test code so that to get a single test failure.
  2. Write enough production code to get all your tests to pass.
  3. Refactor until the code is Simple/Clean. (See elsewhere for the Rules of Simplicity/Clean)
As Brett Schuchert points out in that blog post, leaving out the refactoring step puts you onto the road to certain doom.

No comments:

Post a Comment