Code Kata

Software development is a difficult task. It requires us, at the very least, to be fluent in a programming language, to know the APIs of libraries and frameworks, to know our development tools and methodologies, and to handle the problem at hand. It is only through much practice that we can achieve the skill level and knowledge required to master this craft. On the way, it is likely that we fail in our task. Wouldn’t it be better if that didn’t happen in a real project, where our heads may roll in consequence?

The idea behind code kata is to repeat a small task on a regular basis, with the goal to improve with every repetition. The term was probably coined by Dave Thomas, co-author of the book The Pragmatic Programmer, in a bow to the Japanese concept of kata in the martial arts. We could, for example, perform a known kata in an unfamiliar programming language to get to know it better, or set ourselves the constraint to use the mouse as little as possible to learn keyboard shortcuts. Since we’re working on a small, clear problem, we get the chance to actually focus on improving our skills.

I practice kata irregularly, admittedly, but whenever I find the time I find myself learning a lot from the execution and in reflecting about what I did afterwards. I like to record my executions, both for me and for others to watch. I would be happy, if you would watch the one or the other episode and told me what you think of it! If you have your own executions recorded and published somewhere, let me know, I’m happy to give feedback myself.


Develop a function that maps from a number to either “Fizz” – if the number is divisible by 3, “Buzz” – if the number is divisible by 5, “FizzBuzz” – if the number is divisible by both 3 and 5, and the number itself otherwise. You may know this game from you math classes in school. I recommend you to practice TDD, baby steps, or micro-committing with this kata.


Develop a price calculator for selling copies of Harry Potter books. The books have a fixed price per copy, but you receive an increasing discount with the number of different books you buy from the series. Practice abstraction from business rules with this kata.

Prime Factors

Develop a function that computes the primes factors of any given (positive) number. Focus on TDD and baby steps to see how the choice of the next test influences the evolution of you business logic. Remember to refactor ruthlessly whenever a new tests turns green.

String Calculator

Develop a function that parses a string to compute a value from its contents. Good practice to get to know string manipulation capabilities of your programming language. The problem is a little more complex and can easily be extended by further requirements. This kata is very good to practice adding unforeseen functionality to an existing system. Practice simple design and refactor to master this one.

Share this: Facebooktwittergoogle_plusredditpinterestlinkedinmail | Follow me: twittergoogle_plusyoutube