Over the last several days I've had the pleasure of preparing a performance of the "Bowling Game" kata, originally by Robert C. Martin, as part of my apprenticeship at Clean Coders Studio:
Since the development of Organum in the middle ages (and probably well before that!), composers and musicians have been using variation to restate musical material. One musician produces a melody which, another likes enough to restate (but with some variation), to which another musician replies, and on and on...
There is a long and storied history of classical music composers employing variation in their compositions, but this idea isn't limited to music. One of the most effective ways for computer programmers to develop their skills is by composing and practicing "code katas", which themselves are a variation on the martial arts theme of the 'kata'.
The performance above can be considered a variation on Martin's original in that it is implemented in the Clojure programming language (which is itself a variation on the Lisp programming language). This performance also deviates from the original in making use of incomplete/unfinished games as valid test inputs. (I omitted the usual bunch of gutter balls to 'finish' the 'spare' and 'strike' test scenarios.)
The background music was chosen very deliberately for this performance and consists of several excerpts of "The Goldberg Variations" composed by Johann Sebastian Bach and performed by Kimiko Ishizaka as part of "The Open Goldberg Variations" project, which is free of copyright (all uses allowed).
The "Bowling Game" kata has helped me cross many a technical chasm over the years. It's one of the first things I implement when learning a new language, or trying out new testing tools, or experimenting with new code editors, etc... It's become part of my standard repertoire, just like Bach, Beethoven, and Brahams form the standard repertoire for serious classical musicians.
Generally with code katas the purpose has little to do with the end result, but has everything to do with the processes and techniques employed to achieve it. The same kata can be implemented in any number of ways to hone a particular skill or convey a technique or idea.
So, if you've never attempted the bowling game (or any other kata), what are you waiting for? Run through it a few times to find your bearings, then record yourself and make notes of your strengths, weaknesses, and/or inefficiencies as you watch. See if you can arrange the tiny steps you take to resemble ideal approaches to common challenges you face when working on actual programming projects. Over time, your practice of code katas will pay off as muscle memory kicks in and you elegantly wield your tools to produce meaningful value in the world.
As for this performance, I'm most proud of my application of this bit of wise counsel from Kent Beck:
For each desired change, make the change easy (warning: this may be hard), then make the easy change. --Kent Beck
Can you spot those instances in the video?
Here are the excerpts from The Goldberg Variations used in the video, in order of appearance: