Best Practices, Resources

Learning TDD

I’m currently intrigued with how TDD (Test Driven Development) can help me become a better developer. The problem is…you see TDD mentioned a lot on the Internet, but it’s hard to come across good explanations of HOW to actually DO Test Driven Development.

I first became interested in learning TDD because I read in the book I’m reading now called The Clean Coder: A Code of Conduct for Professional Programmers that TDD isn’t optional–it’s required if you want to be seen as a professional coder, which of course I want to be! 🙂 In the book, Robert Martin discusses using Katas for TDD, so I thought I’d give it a try.

What is a TDD Kata?

TDD Kata was first introduced in the book The Pragmatic Programmer: From Journeyman to Master (which I have yet to read…it’s next on my list). Essentially, it’s taking a set of predefined programming steps that take you through a programming problem from start to finish, using proper TDD techniques right from the start. Its goal is to teach via muscle memory. This blog post describes it well.

My First TDD Kata

Today I did The Bowling Game Kata (linked below) from start to finish. I plan to do it daily for 15 minutes (as suggested by Marlena below). I definitely see the benefit now.

My first reaction as I went through each step of the kata was to check to make sure my logic was correct…but then I realized that that’s why the test was written before writing the logic–it was already verified to be correct since the test passed. Still–I found it hard not to try to run through the logic to make sure (which is muscle memory from non-TDD habits–exactly what I’m trying to break :)).

Fun!

TDD/TDD Kata Resources

Here’s what else I’ve come across that I’ve found helpful thus far in terms of TDD:

Marlena Compton’s Learn TDD with Katas

Marlena describes a 15-minute-per-day technique of learning TDD using Katas. The point is to follow the Kata step by step, which goes through the proper method to do TDD, bit by bit, day by day, to practice and make the act of writing tests before logic the most natural and comfortable way of coding for you.

Jon Reid’s Xcode TDD Kata: Practice with the Bowling Game

Jon adapted this Java TDD Kata so it is in both Objective-C and Swift. It describes what TDD Kata is, and how to do it.

Martin Fowler’s Mocks Aren’t Stubs

Martin describes the different ways in which you can create your app’s objects needed to test your app. It’s an oldie, but I found it to be very good at describing different techniques for actually building your tests for TDD.


I’ll update this post as I learn and find more resources!

-Justin

Standard