Sign in to follow this  
caseyd

State Manager Questions

Recommended Posts

caseyd    276
I'm currently putting together a game framework for the development of 2D rpg's/arcade style games. I created a CMessageHandler as my most base class and am currently starting work on my state manager. I'm really still pretty new to the OOP approach of programming. Am I right in saying that my StateManager class should inherit from the CMessageHandler class or should it inherit from the CApplication class which inherits from the CMessageHandler? Should it inherit from anything at all? I know that these questions probably don't have a simple answer as it would really depend on the design. Any input would be most appreciated. [Edited by - caseyd on August 2, 2005 10:05:43 PM]

Share this post


Link to post
Share on other sites
Argus2    140
Very hard to supply an answer without a clear idea of the roles of those classes. If you're not sure when to use inheritance, I would avoid using it entirely to begin with. Then if the functions of certain classes overlap, or you need to be able to access a bunch of different classes in a similar way, then start thinking about inheritance and OOP.

Share this post


Link to post
Share on other sites
Spudder    385
I'm using a heavily modified version of the state manager design detailed here, the article itself is quite short but it should give you some ideas of how to approach designing your state management system.

Share this post


Link to post
Share on other sites
pi_equals_3    517
Inheritance can be a hard thing to figure out. There are no definitive rules out there about what you should do, but there are definitely ways to tell if you're doing things wrong.

Just figure out what each class needs to do, and if you find a lot of commonality, or you find that you need to use an interface, then maybe you need inheritance. So, does your state manager need to handle messages? Should it have all of the functions of a message handler? Will some function need to send messages to the state manager without necessarily knowing anything about the state manager?

If you inherit something and never end up using anything from the base class, then obviously you didn't need to do so in the first place.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this