Will Springer - Security Developer

Why Practice Code Katas?

I started doing code katas when I started learning TDD. At the time, I thought their purposes was to learn how to solve the problem at hand. Over time, I’ve come to appreciate that this is not the goal of doing katas.

What is a Kata?

A kata is simple programming scenario. They are similar to what many refer to as “LeetCode” exercises, but with a completely different end goal. Instead of trying to solve a novel problem, a kata is an exercise you solve and then repeat over and over again. The value in repeating the exercise is to refine your approach to the problem and learn it inside out. This yields some amazing benefits.

Imagine you play the guitar (if you don’t already). You might have a go-to song that you’ve practiced over and over and know like the back of your hand. Let’s say that you go to a music store and you try out a new guitar. If you play this song you know so well, you can focus on identifying the differences between your guitar and the new guitar (the sound, feel, playability, etc.) without focusing on the song at hand. You control for the song , which lets you focus on the other variables.

Having a handful of katas that you practice regularly in a variety of contexts is like learning a go-to song. If you want to learn how to practice test-driven development (TDD), you can practice those skills with a kata you know well. If you want to learn more about programming in a functional style, you can try that paradigm with a familiar kata and concentrate on the differences between how you’ve performed the kata in the past. If you want to learn a new programming language, try doing a familiar kata in that language.

You don’t need to know a ton of katas to get the benefit from them. My go-to is the mars rover kata, but I plan to pick up a few others to have a little more variety. I think somewhere on the order of 2-5, each with differing contexts, would be a good number.

Katas provide a familiar sandbox for you to try out new ideas and practice building new skills in a comfortable setting.

Some Other Skills You Can Practice Using Katas

Development isn’t all about writing new code. There are other skills that are important to practice as well. Here are a few ideas that I can think of that may be helpful:

  1. Refactoring - after you write your kata solution, refactor it. Try to identify any code smells and refactor the code accordingly.
  2. Architecture - try adding/changing the functionality/features of the kata and see how easy/hard it is for you to make those changes. If it is really hard to make changes to your solution, it may be indicative of a problematic architecture.

Places You Can Find Code Katas

Here’s a great Github repository containing a bunch of different katas: Awesome Katas