TDD is hard, but it's tough to beat well-tested code

I just spent a couple of weeks doing TDD with somebody at work. He knew about TDD and unit testing in general, but he wasn't necessarily convinced about the trade-offs of TDD, especially for somebody with no previous experience doing it.

It takes time to learn TDD well. The initial feeling is that you can go ten times faster if you didn't have to write those darn tests. I get those that stop doing TDD after trying for just a few days; it's hard to envision the long-term gains while you are feeling so much pain to make any meaningful progress.

If you are going through this, don't stop. TDD is hard, but not harder than the other million things that you already learned. TDD will set apart your work; you'll be the one doing what the other hundred aren't just because they didn't take the time to learn it correctly. You can do better by sticking with it and overcoming the challenging phase. Eventually, TDD becomes second nature, and you'll be ripping off the benefits of your hard work.

The fact is that it's tough to beat well-tested code. There'll always be a thousand justifications to avoid unit testing, but at the end of the road, the better code always wins.

Have something to say about this post? Get in touch!

Want to read more? Visit the archive.