A couple of years ago, I read an interesting book chapter by Robert C. Martin and Robert S. Koss. It demonstrates how pair programming and test driven development works, by implementing a simple program that scores a ten pin bowling game. Although the episode demonstrates the use of these techniques extremely well, I always thought that the resulting libraries design was not optimal, because it would be hard to reuse the code inside a more complex (G)UI application.
Some years later, I was asked to repeat that this exercise as a work sample, while applying for a job.I took the chance to challenge my assumptions and develop the application including a GUI using TDD. I started with the GUI, so that the customer has something to look at and play with. This would also enable me to prove that a different and more versatile design will emerge, when a GUI is present. Of course it was also a possibility to show of bit, by developing UI code using TDD. As anticipated, the UI code proved to be extremely challenging, as the scoring rules of bowling are straight forward on the first view, but have a lot of exceptions and extra ifs, especially on the last frame. I ended with a well crafted, well tested, but rather complex application.
Since then I use this bowling scoring sample to get myself familiar with new technologies and programming environments. The rules of bowling are easy to grasp and still complex enough to write a manageable and simple application. When you start to add applications to track a complete bowling league, the sample can scale even to a small and complete distributed system.
The first version I wrote about was written in C# 3.0 using WindowsForms, Spring.NET, RhinoMocks and NUnit.
I’m currently working on a Java version using Java 1.6, Maven, JUnit 4.x, Spring and Swing. I plan to extend it into a multi tier bowling league tracking application using a SQL Database, Hibernate, and building multiple client and server versions using Wicket, Eclipse RCP, Eclipse RAP, Qooxdoo and JEE.