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:
- Write enough test code so that to get a single test failure.
- Write enough production code to get all your tests to pass.
- 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