Code katas

July 24, 2012

When I was a kid I remember taking a karate class for gym. During the class we were taught to perform “katas”. Katas were a series of moves that would be performed after one another in a set sequence. Almost like a dance. Right punch, left punch, right kick, left kick, etc. To a 8 year old I thought it was the most boring thing in the world. And when I learned about Code Katas many years later, I had the same wrong first impression.

Code Katas are problems that programmer can preform over and over again. The focus isn’t on the answer to the problem, but the process in which its solved. Katas are meant to help practice good TDD habits and train programmers to look at problems as a series of failing tests.

Though katas may a first glace seem like a waste of time, they aren’t. After trying out a few, and solving them over and over again I definitely felt the Flow. The Flow is the feeling one gets when they are doing TDD right. Red, Green, Refactor. Almost every programmer knows this idiom, but I don’t think they all have felt it. TDD, when done correctly, is a super responsive feed back loop.

  1. Don’t write any production code without writing failing test
  2. Don’t write more test code than it takes to create a failing test
  3. Don’t write more production code than it takes to pass the test

When following these steps each TDD loop should take a little under a minute. After doing this 15 minutes strait one will start to feel the Flow, and productivity will take off.

Every programmer should practice katas as they teach how to get into the Flow. Once in the Flow you’re biggest worry becomes how to make sure you’re not taken out of the Flow.


Profile picture

Written by Eric Koslow a programmer with too much time on his hands You should follow them on Twitter