Sunday, August 26, 2012

Use a martial arts principle to improve your Test Driven Development skills.

In ancient Japan, martial arts were not just defence techniques, they were also  a way of life(jap. budo”).
In this way of life they combined physical, moral and spiritual dimensions with the goal of self-improvement.

Since very young, Japanese kids would join a martial arts school, to study: karate, aikido, judo…  
They learned martial arts using a technique called “Kata”.

The “Kata” technique was based in the principle of “learn by repetition”.
By practicing exercises in a repetitive maner the learner  comes to a point where develops the ability to execute those exercises and movements in a natural and reflexive maner(“intuition”).

Today in software development the amount of trainers that recommend to use Test Driven Development Katas, is increasing.  Some would even say that the TDD katas, are the only way to learn TDD.  The original idea of the kata as a maner of learning software development was introduced by Dave Thomas(author of: The pragmatic Programmer: From Journey man to Master ).

Programming principles such as KISS(Keep It Simple and Stupid) or YAGNI(You Ain’t Gonna Need It ) are very common in the TDD philosophy, but the main mantra behind TDD is the RGR principle (Red, Green, Refactor).

From the theoretical point of view, the RGR principle seems often very simple to new TDD developers.
But when it comes to real life practice, in many occasions the complexity of the software can make less experienced developers to panic.

A great practice to avoid this is to practice a TDD kata once in a while.
Peter Norvost(author of the blog: Geek Noise), recommends to new TDD developers to do simple katas of 30 minutes every morning for 2 weeks. 
Now I will show you an example of a very simple TDD kata and then I will perform a demonstration.

KATA #1: THE STRING CALCULATOR (Kata description taken from:
1-An empty string returns zero
2-A single number returns the value
3-Two numbers, comma delimited, returns the sum
4-Two numbers, newline delimited, returns the sum
5-Three numbers, delimited either way, returns the sum
6-Negative numbers throw an exception
7-Numbers greater than 1000 are ignored

Note: Don't forget to set the quality to HD in the video player


  1. I’m so lucky today that I was able to read your post which gives me a lot of ideas .thanks for a post

    1. You're welcome, glad my post inspired you.
      All the best with your ideas :)

  2. this is a fantastic post. Thanks Djordje

  3. This comment has been removed by the author.

  4. This is great stuff Djordje. It is easy to follow and demonstrates the power of TDD. I am going to recommend this tutorial to developers that get started with Test Driven Development, well done!

    1. Thanks for your comment.
      Glad you liked it :)

  5. This comment has been removed by the author.

  6. You can find some great katas at -- and some of my own solutions at (though I've since learned enough more Ruby to probably have better solutions)

    1. I knew codekata is great there are a lot of exercises very good to practice. I will have look a codosaur also. See ya around, Thanks for sharing those URLs :)

  7. This comment has been removed by the author.


Share with your friends