For review: I'm looking for critiques/advice regarding the PlayerGame class in particular (3rd block below), where I've located the primary game logic.
Two basic questions:
- Does this
PlayerGame class qualify as 'single responsibility'? If not, what should go?
- For a program this small, are the direct dependencies (see
.bowl and .score_game - instance creation in each case) worth injecting or otherwise minimizing?
The game logic had to go somewhere, and PlayerGame seemed like the best place. The remaining classes are fairly well isolated/dumb. That means PlayerGame is directing instance creation; the dependencies are at least isolated in private methods, but it seems like I could/should do better.
I'm wondering about a) Moving instance creation outside the class entirely (I think this would involve learning more about factory patterns. In practice, though, would you typically bother with the extra layer in a program this small?); b) Removing the turn-by-turn score data from PlayerGame and encapsulating it in a different class (Or do frames-played and scores really belong in a common object?); and/or -- c) Rethinking the modeling entirely (Trying to get away from gameplay as instance creation?).
For review: I'd appreciate critiques/advice regarding the PlayerGame class in particular (3rd block below).
The actual game logic had to go somewhere, and PlayerGame seemed like the best place. The remaining classes are fairly well isolated/dumb. That means PlayerGame is directing instance creation; the dependencies are at least isolated in private methods, but how could/should I do better? I'm also not at single responsibility for this class yet. Should I:
- Move instance creation outside the class entirely? (I think this would involve learning more about factory patterns. In practice, though, would you typically bother with the extra layer in a program this small?)
- Remove the turn-by-turn score data from
PlayerGame and encapsulate it in a different class? (Or do frames-played and scores really belong in a common object?)
- Or -- rethink the modeling entirely? (Try to get away from gameplay as instance creation? Other approaches?)