Since the problem can be solved, and has been solved, in programming languages that do not support object-oriented programming, there is obviously no unique "right" factoring of this problem into classes.�� I'll be honest with you: this is the only Pharo exercism I have not tackled, and the reason is that I just found the problem specification too ugly to care about.�� I had better get over that.
The two primary difficulties are
(a) the game is described one ROLL at a time, but scored one FRAME at a time.
(b) the rolls are recorded from past to future, but the score can only be
calculated from future to past.
The fact that there may be one extra roll at the end which is not technically
part of any of the 10 frames is just icing on the cake.
But this is *algorithmic* trickiness, not *world model* trickiness.
Let's imagine a Frame class.
- You get the first roll of the frame.�� Fewer than 10 pins are knocked down.
�� You cannot complete initialising the Frame yet.
- All 10 pins are knocked down.�� You cannot determine the *score* of the
�� frame yet.�� This casts some doubt on the idea of the score being part
�� of the state of the frame.�� The score actually depends on the next two
�� THROWS (rolls), not the next frame or the next two frames.�� This casts
�� much doubt on the idea of the concept "frame" being useful for the
�� analysis.�� At the very least, you will need to manipulate BOTH frames
�� AND throws (rolls).
It looks as though a Frame class may just make things harder.
Since the only thing there is to know about a Throw is how many pins
were knocked down, it doesn't look as though a Throw class is much use
either.�� This leaves us with a BowlingGame class that just keeps tracks
of rolls and then runs a moderately complex algorithm when it is asked
for the score.
Long past my bed-time or I would get stuck into it.