After a good nights sleep, it occurred to me that I don't want to create a monolithic singleton. Not necessarily because it is a singleton, the emphasis is on monolithic. Having a single class implement all the game list and individual game state transaction logic feels like a serious violation of the single responsibility principle.
So, here's a quick and dirty class diagram of what I'd like to implement:
GameListScene
will be responsible for holding a GameList
instance. This is the only scene in the game that will expose the list to the user, and so there's no current requirement that says it has to be passed around. The GameScene
instance is going to be where the action takes place. Both GameList
and Game
will be responsible for talking to the REST API. One of my reasons for going with the singleton, was to hide the url and http stuff from the client (GameListScene
and GameScene
). In order to accomplish this, I've decided to let them inherit from RESTClient
. This way, I can keep at least keep the http stuff hidden while not repeating myself.
The bottom line is: I've got more classes with this design, but hopefully it'll prove to be a cleaner and easier to maintain.