Monday, March 21, 2011

Introducing the Code Kata project

One of the common themes that people talk about when it comes to craftsmanship is practice.  Dave Thomas made the corollary for programmers a few years ago in this blog post.  He brings up great points about not worry about the answer but instead focusing on how you got to the answer that you implemented.  It also emphasizes repetition meaning you should practice a kata frequently.

I love the idea of the kata but I found I had a few ideas that could make the process more effective and prove to have wider adoption not only in the ruby community but all programming languages.  The ideas I had could be summarized as follows:

  • Authoring - I wanted a consistent way to write a kata that would clearly illustrate the requirements through details and examples.
  • Administering - How do you take a kata?  I wanted a way to step through the requirements and measure progress by how many requirements I completed and how much time it took to complete them.
  • Setup - I wanted to be able to chart my progress over time by using source control to keep track of the code for each time I took that kata in an automated fashion.

The result of these ideas is the kata gem.  Check the github page for all of the details but briefly it provides the following:

  • An RSpec like DSL for authoring katas using descriptive keywords like requirement, detail and example.
  • A command like tool to self-administer a kata by stepping through the requirements
  • The ability to automatically create a distinct github repo for the kata you wish to take allowing for later code review.
Now that we have tools in place to make us more productive in writing and taking katas we just need katas to test ourselves with.  I have created the code katas project so that everyone has the opportunity to contribute and take advantage of the efforts put forth. 

If you just want to take a kata that is part of the project it is very easy to get started if you are used to using rvm and bundler.  Just clone the repo:

change into the cloned repo:

Install your bundle:

Now you can setup your github repo to take your kata:

At this point you can cd into the created directory and view the repo in your github account. You can commit to it but should ignore it in the code_kata project.  All the goodies like autotest and kata are installed so you can follow TDD best practices without any work on your part.

In a separate terminal window you can then administer the kata to guide you through the requirements for the code you need to write:

You are off and running to practice regularly!

What the project needs though are obviously more katas.  String calculators are great and thanks to Roy and Katacasts for inspiration but more can be done.  Translation and updating of the original katas from Dave Thomas would probably be a good start but what ideas do you all have?  For the code kata project and submit your ideas for everyone to grow and get better!