Hi all,
So this question is a sort of follow on from here (http://stackoverflow.com/questions/1914097/how-to-deal-with-multiple-event-args). That question led me onto thinking about this but is different enough to warrant its own thread.
I am creating a game (for fun and learning purpose) and would like to know if I am using good standards for design or not. I think I might have gone OTT on separation of concerns, or just got the whole thing wrong, but I am hoping that isn’t the case. I have no problem rewriting it as I want to learn “best practices” and the practical application of them.
EDIT
Let me explain a little more about the game, It is based on Jawbreaker a game found on many mobile phones (quick demo found here). Objective is to select balls that are in groups to remove them from play and score as many points as possible.
I am trying to expand it a little and have different types of boards, balls move in different ways, and different ball types, the balls may just go where they are told to, or they might do something along the way.
So Here is the structure of the objects I have created, top row shows the DLL’s with their Objects, second row shows what those objects reference:
Here is my attempt at doing the UML:
Click here to link to full page for UML, makes it a little larger and hopefully easier to read
The Objects DLL holds the basic objects used in the game, Balls and a Board. They do not contain any logic about how they act / react to situations (the ball does implement the CompareTo and the Equals methods). There could be X number of implementations of IBall (and the same for IBoard, although there will not be that many I imagine).
The InstanceManager DLL is used as a way of Creating Objects, not sure this was 100% needed it could have gone in the Objects DLL. The Factories are static classes that have various overloaded methods to create IBall objects. The BallFactory can take the BallType Enum, A Drawing.Color object, etc. The BoardFactory is very similar. Jawbreaker is a singleton object that deals with things like holding a Random Object as it is used very regularly and some GameConfiguration data, (not so relevant to this topic).
The Engine DLL is where most of the work happens. The LogicFactories take the BallType and BoardType objects to create the relevant Logic Objects. The logic objects are used to control how an IBall and IBoard object works. The BallLogic tells the ball what it can do when its events fire. For example when a Ball is selected a method is called on the Ball Logic saying Ball X on Board Y has been selected. The Ball can then do whatever its type of ball should / could do. The BoardLogic is very similar and deals with how the board acts.
The Engine Object is another singleton and is how the GUI would interact with the whole game. The GUI would not instantiate any of the other objects directly.
So to summarize the IBall and IBoard classes hold just the data about them, the Logic classes deal with all the functionality.
What I would like to know is:
1) Is this a sensible approach?
2) Should (in general) Logic be separate from the Objects / data?
3) Have I gone too far with the separation of concerns?
4) Any other comments about the design / structure
EDIT
The reason I have used a couple of singletons is partly for simplicity of accessing the data in one place without keeping hold of objects all the time and also just because it is a single game and will not be scaled to either high end or across multiple machines. I do understand that they are not great and its not something I use regularly, but appreciate the comments.
Thank you for your thoughts and feedback.