The kata is well-documented online, but briefly, the idea is to write a program that takes in a series of scores for each ball a person bowls in a bowling game and returns the resulting game score. And to guide us towards code the open to extension and closed to modification, we’re going to follow the workflow described at http://matteo.vaccari.name/blog/archives/293. This is how it works
- Write the first failing test. It should use a factory method to obtain the object(s) under test.
- Make the test pass.
- Write the next failing test.
- Try to make this test pass by only changing the factory and/or adding new classes.
If you find yourself modifying or adding functionality in existing non-factory classes
- Refactor the code so that you could proceed without changing these classes. The refactoring itself should provide no functional changes and the current test should still fail after the refactoring.
- Now make the test pass.
- Go to step 2.
Version control your code and commit frequently, so that we can see the process you went through at the discussion group.
You are free to implement the bowling game scorer in whatever order you want to, so long as you follow the workflow above. However, you might want to follow the suggestion below. If you need a hand with the bowling terminology and scoring rules, take a look at http://bowling.about.com/od/rulesofthegame/a/bowlingscoring.htm.
- A gutter ball game, where every bowl provides a score of 0.
- A one pointer game, where every bowl provides a score of 1.
- A game where many pins are knocked over in each bowl.
- A game where the first two bowls result in a spare.
- A game where the first bowl is a strike.
- A perfect game of all strikes – don’t forget that throwing a spare or strike in your last frame gives you up to an additional 1 or 2 shots (respectively).
Also in Software development
In 2018 we ran the industry’s first ever state of SQL Server monitoring survey. We received an excellent response from over 600 people in a range of sectors, in organizations of every size across th...
Also in Blog
In the R&D division of Redgate, Foundry, we're working on a new tool, SQL Census, in an effort to make your SQL Server permissions more manageable by seeing who has access to your servers and rest...
Also about Code Katas
First, apologies for nodding off and not posting for the last few weeks. I have the usual set of excuses, which you can guess easily enough without the need to read them here.
So, on to the kata: som...
Also about SOLID
Let’s get this clear: we’re not going to write a chess-playing AI in this kata. The idea is a bit more humble: to write a program that can work out valid moves for a set of chess pieces....