Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • 1
    +1 - I'd probably stick the context in the constructor, but yes you need the State object that controls the logic and the context that holds the data. Commented Feb 4, 2012 at 11:41
  • @TheMouthofaCow: Honestly, that was a close call. I don't have a strong preference. On one hand, if it's held in the State objects and the application, there is a risk of over-ownership; on the other hand, this way does mean passing context to every method. Commented Feb 4, 2012 at 13:12
  • it's an implementation detail :) Commented Feb 4, 2012 at 16:15
  • @pdr, thank you for the detailed example and explanation. I understand what you're saying. My implementation is a little different, I'm going to edit my question with more detail. Commented Feb 4, 2012 at 21:36
  • @Kal_Torak: Please provide more info for a more specific answer. If you have a main room, I assume this is a client-server game. If so, where is your Context.CurrentState singleton? Client or Server application? Should it be a singleton, or should it be per-game? (The game is where a state is more logical - the main room is just a list of games with open spaces, no?) Commented Feb 4, 2012 at 22:07