Skip to content

tonyx/katabowling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 

Repository files navigation

OCP KATA BOWLING 


An implementation of the bowling game in a way inspired by the "ocp rules":

http://matteo.vaccari.name/blog/archives/293 

Particular instances of bowling games are constructed by a factory where you can inject rules like validity of frames and how to compute scores.


The original bowling kata description by Robert Martin is here: http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata


Ocp kata:
The ocp kata tecnique forces the respect of the open closed principle. 
Any new feature must be implemented by extensions and no modifications of any existing module but the factory. 
If it is not possibile, then the test for the new feature must be ignored, and a refactoring is needed in order to make the preexisting base ready to implement the new feature following the open closed principle.
After this refactoring  the test must be de-ignored and the code that makes the test pass can be added (respecting ocp by definition).


notes:
may be there is the need to check a "legacy" source of bowling score calculation. Here there is one:
http://tralvex.com/pub/bowling/BSC.htm

The code has been developed in C# 3.5 with dot.net, and also compiled and tested in mono 1.9.1 with Ubuntu s.o.

Seems to me that the solution is already closed to modifications for any new bowling game instance if:
- the frame cration constraint can be expressed in terms of boolean expression applied to the frame
- the bonus for any frame can be expressed by a function that returns an integer applied on the entire frames sequence and the current frame index.

The "martian bowling" game rules are an example of this because there is a different rule to compute the bonus and to validate the frame.