Skip to main content
Code Review

Return to Question

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

This is a complete rewrite of code I first posted for review here here. My first solution was entirely procedural (all methods, no classes). I got some great pointers on OOP basics in the response, plus a referral to Sandi Metz, and worked out a new solution on that basis.

This is a complete rewrite of code I first posted for review here. My first solution was entirely procedural (all methods, no classes). I got some great pointers on OOP basics in the response, plus a referral to Sandi Metz, and worked out a new solution on that basis.

This is a complete rewrite of code I first posted for review here. My first solution was entirely procedural (all methods, no classes). I got some great pointers on OOP basics in the response, plus a referral to Sandi Metz, and worked out a new solution on that basis.

edited tags
Link
200_success
  • 145.5k
  • 22
  • 190
  • 479
Changed paragraph order to make review questions more visible
Source Link
a2bfay
  • 215
  • 1
  • 7

Multiplayer bowling in Ruby, with variable skill (follow-up: injection, single responsibility)

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:

  1. Does this PlayerGame class qualify as 'single responsibility'? If not, what should go?
  2. 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:

  1. 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?)
  2. 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?)
  3. Or -- rethink the modeling entirely? (Try to get away from gameplay as instance creation? Other approaches?)

Multiplayer bowling in Ruby, with variable skill (follow-up)

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:

  1. 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?)
  2. 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?)
  3. Or -- rethink the modeling entirely? (Try to get away from gameplay as instance creation? Other approaches?)

Multiplayer bowling in Ruby (follow-up: injection, single responsibility)

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:

  1. Does this PlayerGame class qualify as 'single responsibility'? If not, what should go?
  2. 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?).

deleted 83 characters in body
Source Link
a2bfay
  • 215
  • 1
  • 7
Loading
Added clarification to one question.
Source Link
a2bfay
  • 215
  • 1
  • 7
Loading
Source Link
a2bfay
  • 215
  • 1
  • 7
Loading
lang-rb

AltStyle によって変換されたページ (->オリジナル) /