Coding katas: practise your craft

Small exercises, big benefits, and a lot of fun

What is a coding kata?

In martial arts, a kata is a fixed sequence of moves that you repeat over and over until it becomes second nature. A coding kata is the same idea for programmers: a small exercise that you solve, throw away, and solve again, each time a bit better. The term was made popular by Dave Thomas, co-author of The Pragmatic Programmer, who also runs a collection of exercises at codekata.com.

The problems are small on purpose. Think of FizzBuzz, converting Roman numerals, scoring a bowling game or Conway’s Game of Life. The point is not to deliver a feature, but to practise: test-driven development, refactoring, a new language or simply a cleaner way of thinking.

Advent of Code

If you want a taste of this, have a look at Advent of Code. Every year in December a new puzzle appears each day, and you can solve them in any language you like. The puzzles start easy and become more tricky, and there is a nice community around it. For many engineers it has become a yearly tradition, and it is a perfect excuse to try that language you have been curious about.

Why it is both fun and useful

Katas are fun because there is no pressure. No product owner, no deadline and no legacy code, just a problem and you. At the same time they make you a better engineer. You build muscle memory for your tools and shortcuts, you practise techniques like TDD without the risk of breaking production, and you learn how other people solve the same problem.

Doing the same kata twice is especially valuable. The second time you will see how much faster, and how much cleaner, your solution gets.

Katas in your team

A kata makes a great team meeting. Pick a small problem, and solve it together in pairs or as a mob, where one person types and the rest of the team thinks along. Rotate the roles, try a different language, or let everyone solve it separately and compare the results afterwards. It is a relaxed way to learn from each other, and it works for juniors and seniors alike.

It also helps your engineering culture. Regular practice, outside of delivery pressure, shows that learning is valued. People feel safe to try things, to make mistakes in front of colleagues and to ask questions. That kind of safety is what you want in a healthy team.

A tip for your career

Put your solutions on GitHub. A repository with a few katas or your Advent of Code solutions, with a short README, some tests and a clear commit history, shows potential employers how you actually write code.

Give it a try

Pick a kata this week, give yourself 30 minutes and see what happens. And if you are reading this in autumn: December is not far away.