Many really smart people tell us we have to use TDD if we want to create code that is worth a penny. For example take this article about TDD by Uncle Bob (one of the moderate ones). He describes the benefits of TDD in paragraphs like this:

If all your code works every minute, how often will you use a debugger? Answer, not very often. It's easier to simply hit Ctrl-Z a bunch of times to get the code back to a working state, and then try to write the last minutes worth again. And if you aren't debugging very much, how much time will you be saving? How much time do you spend debugging now? How much time do you spend fixing bugs once you've debugged them? What if you could decrease that time by a significant fraction?

But the one thing he does not provide is anything close to a proof. He offers his own experience, which might be distorted for all kinds of things.

Yet with a practice so simple (note: I didn't write easy) as TDD and so many people advocating it one would like to see some proof of the benefits of TDD. After writing a little piece about opportunities for more research in software development I was recommended this the book: Making Software: What Really Works, and Why We Believe It. It is highly recommended for anybody interested in what works and what doesn't work in software development. Just be warned it is a little harder to read than Harry Potter

There actually is a chapter about TDD in it. The result: Not a clear win. I'm not even trying to put the details in here, but the result is basically: Although they tried they couldn't prove TDD to be as effective as many people claimed. But they also showed it is not as costly as many people claimed. And I think they mist at least one point: TDD can teach you a lot about software development and software design on the micro level.

So what is the answer to the question in the title: Do we have to do TDD?

Nope, don't think so. There are alternatives, like writing your tests after the code. But I recommend TDD to everybody to try it at least for some time. Its a great chance to learn a lot.

Talks

Wan't to meet me in person to tell me how stupid I am? You can find me at the following events: