Code Kata – The way to TDD

I’ve been playing with the thought of making code kata exercises a daily routine for a while. It never really happened until I read Peter Provost’s inspiring post. If there were only one post you could read about TDD and Code Katas, that post would be it.

After reading the post I took the plunge and jumped right into the first recommended kata – The Bowling Game Kata. It was great timing since every now and then we go out with friends to roll some balls and it was about time for our next great battle. Although once I knew how the scoring worked, couldn’t really figure it out on our last bowling session. That gave some extra boost to go ahead and read the Wikipedia article about the game and relearn the scoring.

Once the rules are clear, you’ll probably want to read Uncle Bob’s post too and download his presentation with step-by-step instructions. Fire up Visual Studio, open up the ppt and try to finish it in half an hour. Although the code on the slides are written in Java, it’s rather straightforward to port it to C# or to the language you prefer. You can do katas in JavaScript using a testing framework like Jasmine or QUnit as well.

Don’t worry if it takes a bit longer the first couple of times, your speed will improve with every iteration. Using tools like NCrunch also speeds up the exercise, not to mention the indispensable ReSharper. Improved Shortcut-Fu is another side-effect you will experience during the sessions.

I also played with the String Calculator Kata, which is Roy Osherove’s favourite kata. He is the author of the popular book: The Art of Unit Testing. If you haven’t done much unit testing before, that is a great book to get into it. Buy it, read it.

If you got hooked on code katas like me, don’t forget to check out Coding Kata .NET and CodeKata for more.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s