April 27, 2014

The Bowling Game Kata in nodejs

I had to ride a train with sketchy internet connection this week, which meant it was finally time to try Bob Martin’s Bowling Game Kata. This is a simple walkthrough of building a system for scoring bowling games using Test Driven Development. It is simple (one class, < 10 functions, often less than 200 lines of code), short (50 code examples, less than an hour to complete), and puts you into Bob’s brain as he points out bits of code he doesn’t like and refactors them.


I completed the kata using Javascript and NodeJS instead of Java. I used Mocha for writing tests. It was easy to translate the exercise to these tools. At the end of the project, I was curious about how to add up scores for incomplete games (< 10 frames), and whether more tests would be necessary to verify the program works because I chose a dynamic language. I was also relieved that none of the suggested refactoring steps seemed out of place to me.

I discovered the –watch argument for Mocha part way through the project, which saved some keystrokes and clicking by automatically running tests when relevant files changed.

I have only completed this Kata once. A Kata is supposed to be completed many times. It should be habit forming. I haven’t decided if this is a good to repeat over and over again. Is it too simple? I’m not sure if I would benefit from this one.

My source code is available on GitHub

More Katas!