@drpicox
HOMEBLOGTESTINGTEACHING

The Bowling Game Kata

Robert C. Martin published the Bowling Game Kata in 2005 at http://www.butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata

He describes the kata intention as:

A kata is meant to be memorized. Students of a kata study it as a form, not as a conclusion. It is not the conclusion of the kata that matters, it's the steps that lead to the conclusion. If you want to lean to think the way I think, to design the way I design, then you must learn to react to minutia the way I react. Following this form will help you to do that. As you learn the form, and repeat it, and repeat it, you will condition your mind and body to respond the way I respond to the minute factors that lead to design decisions.
— Robert C. Martin

It contrasts with other katas that you might know. It is not an exercise of the resolution of a problem; it is the study of each step to create a solution.

The intention is to show and learn TDD. This kata is a profound study of the TDD. It presents a list of steps that you must follow in a TDD development.

The way of the kata is simple: repeat step by step, innovate nothing, replicate what you see. Be careful, do not add extra steps; do not skip any step.

Although you have the code, do not copy blindly. Try to understand each step; try to see the beauty. Enjoy how the code takes form and how the test transforms itself. Learn how tests leverage in the code and how the code leverages on tests. Code changing the internal representation step by step, first adding the new representation, then adding the setters, changing the getters, and finally removing the old code. And all in green.

And repeat, and repeat. Once you have finished the kata, wait a week, and repeat it. Then, wait a few weeks and repeat. Then wait a month and repeat. And then, repeat the kata twice a while.

Updated Kata

Here you have the slides and the instructions to do the kata in

Javascript and Java.
  1. Download the slides for Javascript or Java
  2. Clone the repository at Javascript or Java
  3. Follow the steps of the kata

There are three sections in the slides:

  • The Kata analysis: it replicates the study of a developer of the problem.
  • TDD Overview: it explains what is TDD
  • The Kata

The last section is the exercise itself. Each slide is meaningful by itself and deserves a moment of attention. If you look carefully, some slides have a message on the top right in orange: «commit X.» It starts at zero and increments in one each time that appears. Some slides also have a green or a red bar; it represents the current state of tests. Red if tests are failing, green if tests pass after the current slide.

The code is in a git repository. It starts in the «commit 0,» and it expects from you to replicate each slide in it. Be careful, and go slide by slide. Each time that you finish copying the changes of a slide verify two things: the commit number and the test bar status. If the test bar status matches the condition of your current tests, and there is a commit number, then commit the git repository with the commit number as a message. Once you have finished it, remember to push changes.

Copyright © 2022 David Rodenas
G · T · M π