Does TDD facilitate finding defects?
JavaWorld has an interesting forum discussion entitled “Heinz Kabutz on Bad Code, Unit Testing, and More” in which the following thoughts are posed as a series of questions:
Kabutz also gives Java developers a hard time for not unit testing. He argues that it’s a major problem and that few Java developers do it. I’m curious: Has anyone gotten into big trouble for not unit testing? Is it a major source of bugs in your experience?
The discussion then centers around the merits of unit testing and code coverage (much like the excellent discussions from Stelligent’s TDD Horror stories evening!)– for instance, one reader states:
Striving for 100% unit test coverage is nice for libraries, but overkill for the avarage bussiness application that is written by most development teams.
What are your thoughts? Is TDD worth the effort or not?

November 16th, 2007 at 10:33 am
The topic’s name “Does TDD facilitate finding defects?” brought up some interesting thoughts on another spin that may be taken on answering the question. Here’s the anecdote: If you’re sitting in your office, writing code and you suddenly notice that you’re cold from the lack of sunshine, you may want to step outside for a little while in the sunlight, right? Ok, so you do step outside. What’s the first thing that you once outside? Do you ask yourself “Well, lets identify what spots out here are shady and look cold……let’s see: there’s that place out there in the corner, that spot right over there…….hmmm, i’m going to avoid those spots……..now, lets look for some sunshine…..” . No. We never do THAT. We simple go outside and bask in the sunshine!
So what’s the parallel here? Always doing TDD when coding is like just stepping outside right into that warm yellow glow of the sun and staying there. It keeps you warm and in the light. Does it facilitate finding defects (in other words, does it keep you from stepping into the shady areas)? Sure, but not explicitly. TDD prevents defects from happening in the first place. You don’t really need intentionally find defects if you’re doing everything in your power to write good code.