This blog post has first been published in the Qafoo blog and is duplicated here since I wrote it or participated in writing it.
Cover image for post Coding in Katas

Coding in Katas

In almost any kind of sports you hone your skills by repeating a small piece of practice over and over again. Pretty much the same works for learning to play a musical instrument. The idea of Code Katas applies this simple but effective method of exercise to the world of programming.

A programmer's everyday life mostly consists of a single goal: getting things done. New features are to be shipped, bugs to be found and fixed. While you can certainly learn many new things thereby, this scenario lacks two essential factors for effective learning and self-development: Time to try and possibility to fail. Everyday work is typically not the situation where taking a risk and failing by intention is desired.

So, if you want to grow beyond yourself, you need to create an environment for your practice where failure is allowed. Starting a spare time project or even an open source project can help there. But finding a sufficiently clear and defined task to practice your skills is hard. That's where the idea of Code Katas jumps in:

Kata (型 or 形 literally: "form") is a Japanese word describing detailed choreographed patterns of movements practiced either solo or in pairs.

A Code Kata is basically a well-defined, small task to be solved by programming. The time to solve a Kata should be reasonable to allow you to get started rapidly and to see first results quickly. However, you usually set yourself a time limit, say 1 hour, and stop precisely when the limit is reached. The actual result of this work is only a secondary concern, same applies to finishing the task. What counts is the actual practice. Pushed even further: You might actually want to throw away the code later.

The important part is to reflect on what you did: How did you approach the problem? Where did your approach lead you? What were the problems? What went well? Ideally, ask another developer for feedback or, if possible, directly work in pairs to learn from each other.

And when you are done: Start over from scratch. Maybe directly after finishing the first iteration or a week later. Do the same Kata again. Try a different approach or try the same and see where it leads you after your reflection. Reflect again and set yourself a goal for the next iteration.

With these characteristics, a Kata gives you a good basis to try out something new, to let off steam and to practice your skills as a programmer. Maybe you could try a purely test driven approach now. Maybe you will think about a complete OO model upfront then. And maybe you could apply Object Calisthenics in another iteration.

One of the most famous Code Katas is the Bowling Game Kata by Robert C. Martin. The task of this Kata is to implement bowling with its simple rules. Not a tough challenge, but something with a connection to reality, clearly structured and well-defined. Uncle Bob used this Kata to visualize the methodology of Test Driven Development.

At Qafoo we tend to use Katas more and more frequently in our trainings for practice. Of course, Katas can neither replace practices derived from the real world nor working on own code. But they offer our training attendees the possibility to perform quick practices in-between theoretical lectures and to reflect on different approaches to certain problems in practical trying.

There is a Kata Catalogue where you can find quite some Katas. Tell us about your experience with Coding Katas!