TITLE: Why Not Program Test-First? AUTHOR: Eugene Wallingford DATE: September 24, 2004 11:12 AM DESC: a stream-of-consciousness discussion of choosing TDD ----- BODY: "If you can't write a test for the code you are about to write, then you shouldn't even be thinking about writing the code." And if you can, why not write it now? Then you will know for certain that you can, and that you aren't just fooling yourself. Good programmers sometimes ask me why they should bother. They already write good code. Do such programmers really need the extra discipline of TDD? Perhaps not. But good programmers are people, too, and so are subject to the same tendencies as anyone else. When the pressure is on, or when they are surprised by a new requirement, they are all too prone to tell themselves that they really do understand. There is another, perhaps better, reason for good programmers to practice TDD: good programmers often work as part of a team. And as a member of a team, they depend on the quality of the code produced by the entire team, not just themselves. A good programmer can benefit from having his teammates practice the discipline. In this way, even weaker members of the team will develop better code, which benefits everyone. The good programmers will want test-first to be a team discipline, so everyone practices it. If writing tests first is something you can do anyway, the real question becomes: Why not? -----