Is TDD Worth It? A Positive Testimonial

Shares

Is TDD worth the extra effort? I got a reaction from one person who tried applying my tips.

TDD thank-you note

Thank You Note by Roger Carr, used under CC BY-NC-SA 2.0 / TDD card added to original

Andy Dwelly began applying my TDD screencasts to his iOS coding. Here’s what he writes in Some notes on Test Driven Development:

At first progress was almost painfully slow.

Yup. It seems like there’s a lot to learn. The real barrier, I think, is that there is a lot to unlearn. And so, when you first get started with Test Driven Development, your productivity will take a big hit. This is normal! But if you’re willing to press through the learning curve, your productivity will increase again — in ways you may not have experienced before…

TDD: Immediate Benefits!

I would normally expect to write the final line and then fire up the debugger to get it to actually work.

Except that it did just work.

I experience this fairly regularly, even when I TDD a new view controller.

I think at this point, if I’d been asked anything about the issue of code quality I would have claimed that the actual code produced was marginally better. My TDD code certainly handled errors and failures better, but had poorer information hiding and some dependency injection that I would not normally have bothered with.

Then my tests found a bug that I don’t think I would have spotted until the code hit the field.

Do the math: What is the cost of a fixing a defect vs. preventing a defect? Even though TDD takes more time up-front (when it’s just the developer’s time), it reduces time later (when more people are involved). I think there’s enough evidence out there to make this claim: Once you make it over the learning curve, your time-to-market will be the same — but with many more benefits!

TDD: Limitations?

I’m still of the view that trying to do a lot of UX tests using TDD is hard.

What Andy hasn’t experienced yet is the real powerhouse that TDD enables: refactoring. To me, this is the greatest benefit of Test Driven Development. It’s a shift of emphasis, from “prevent bugs” to “empower change.” And that’s why I’m vigilant about unit testing view controllers, down to the nib connections. Where some people say, “I don’t think that last bit is worth the effort,” my reply is, “It’s often not that hard. Why would you turn down the chance to automatically check your code?”

So Andy is still early in his iOS TDD journey. He’s still approaching it with some skepticism. But it didn’t take long for him to experience some of the benefits! Go read his account.

What are your questions / concerns / reservations / experiences with TDD? Leave a comment below.

About the Author Jon Reid

Jon is a coach and consultant on iOS Clean Code (Test Driven Development, unit testing, refactoring, design). He's been practicing TDD since 2001. You can learn more about his background, or see what services he can bring to your organization.

follow me on:

Leave a Comment:

10 comments
Add Your Reply