Jump to content
  • Advertisement
Sign in to follow this  
ishikawa-san

IManager - subsystem interface

This topic is 4069 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What do you think about this? -> http://img228.imageshack.us/img228/5450/manageryd4.png <- In systems based on smaller specialized components, generalization is needed. In my opinion it's easier to manage them when they all inherit from one base class. Now a little explanation: getManager() - returns a pointer, increment reference counter dropManager() - opposition to getManager, additionaly if reference counter reaches 0, instance is destroyed. process() - this is our big pure virtual method. It's called every frame, so every subsystem does it's job. For instance, GraphicsManager draws everything, etc. getRTTIAlias() & setRTTIAlias - usefull for debbuging I think log() - I don't see a point making logger a stand alone subsystem. It's useless then, becouse logs are coming from highest level. So what if exception in ScriptingSystem has occured? I want to know in which method and class! protected Constructor and Destructor I'm curious what do you think about my idea! Come on, share your opinion it's priceless! Best wishes Ishi-san [Edited by - ishikawa-san on October 28, 2007 2:07:23 PM]

Share this post


Link to post
Share on other sites
Advertisement
The obvious critics:

Quote:
getManager() - returns a pointer, increment reference counter
dropManager() - opposition to getManager, additionaly if reference counter reaches 0, instance is destroyed.


SRP violation, use a non-intrusive smart pointer.

Quote:
process() - this is our big pure virtual method. It's called every frame, so every subsystem does it's job. For instance, GraphicsManager draws everything, etc.


What happens when you need to process in-between frames (for instance, you have to skip frames because the computer is slow) ? What about situations without rendering (such as servers) ?

Quote:
getRTTIAlias() & setRTTIAlias - usefull for debbuging I think


Er?

Also, your Manager can't possibly be both a singleton and a base class, but I assume that's a typo in your graph.

Share this post


Link to post
Share on other sites
Singletons are bad.
Managers are usually bad (or at least, symptoms of bad design)
Singleton managers, by extension, are... not ideal. And singleton manager interfaces probably aren't a whole lot better.

Share this post


Link to post
Share on other sites
Quote:
SRP violation, use a non-intrusive smart pointer.


Why is that? I don't see any influence on cohesion.

Quote:
What happens when you need to process in-between frames (for instance, you have to skip frames because the computer is slow) ? What about situations without rendering (such as servers) ?


Right, this is the method which I'm not sure of. I must reconsider it.

getRTTIAlias() & setRTTIAlias - can you extend your opinion?

And yes, that Singleton in my graph is mistake.

And about what Spoonbender wrote:

Quote:
Singletons are bad.
Managers are usually bad (or at least, symptoms of bad design)


I cannot agree. Where did you heard that? Splitting application into smaller managers (subsystems) is very common praxis. Check out any 3D or Game engine API.

Share this post


Link to post
Share on other sites
Quote:
Original post by ishikawa-san
Quote:
SRP violation, use a non-intrusive smart pointer.

Why is that? I don't see any influence on cohesion.


Not cohesion. Single Responsibility Principle. You're stating, in your design, that get/drop functionality is inseparable from manager functionality. And so, if you need, one day along the road, an object which is not a manager but needs to be garbage-collected in a get/drop fashion (and you will), you will either have to duplicate the behaviour that was already implemented in the manager (a bad thing) or move the functionality to a third module and change your manager's interface to go through the module instead of handling it on its own (tiresome if lots of code are already using the manager). So, I would suggest making the change as soon as possible.

Quote:
What happens when you need to process in-between frames (for instance, you have to skip frames because the computer is slow) ? What about situations without rendering (such as servers) ?


Right, this is the method which I'm not sure of. I must reconsider it.

Quote:
getRTTIAlias() & setRTTIAlias - can you extend your opinion?


Well, I don't see what they would be useful for (or how).

Share this post


Link to post
Share on other sites
Ok, that's important hint, what you've just said. So what do you propose? What kind of garbage collecting mechanism implement? Make a stand alone class with this methods and let all classes inherit from it? I saw such a solution in irrlicht 3D engine.

About RTTI Alias, I think setting a string alias, identificator, makes system logs more readable.

I understand that static log() method leaves no doubt?

Thanks for your help and clues, they are very helpful.

Share this post


Link to post
Share on other sites
Quote:
Original post by ishikawa-san
Ok, that's important hint, what you've just said. So what do you propose? What kind of garbage collecting mechanism implement? Make a stand alone class with this methods and let all classes inherit from it? I saw such a solution in irrlicht 3D engine.


boost::shared_ptr is already out there, written out for you.

Quote:
About RTTI Alias, I think setting a string alias, identificator, makes system logs more readable.

I understand that static log() method leaves no doubt?


In that case, I would suggest instead creating a log class which would handle the RTTI data itself, and merely give the manager that instance of log in its constructor, and have it be returned by your log() method.

Share this post


Link to post
Share on other sites
Quote:
boost::shared_ptr is already out there, written out for you.


What do you think about overloading new and delete operators?

And how would you handle run time type info in this class? I'm against making logger a stand alone class becouse it increases dependencies. But maybe I'm not right, in the end, loggers global inteface won't probably change.

Share this post


Link to post
Share on other sites
Quote:
Original post by ishikawa-san
Quote:
boost::shared_ptr is already out there, written out for you.


What do you think about overloading new and delete operators?


It's completely independent of the issue of garbage-collection, since the memory pointer returned by new will be different from the pointer used by the constructed object (they might even have different addresses) and delete won't be called until you know the object can be destroyed, anyway. You cannot use new and delete to decide whether an object should be deleted...

Quote:
And how would you handle run time type info in this class?


Pass the RTTI info to the logger, then pass the logger to the base class constructor. This allows one to specify a mute logger instead of a live RTTI-id-based one, just in case you want to make one of the managers shut up.

Share this post


Link to post
Share on other sites
Quote:
Original post by ishikawa-san

And how would you handle run time type info in this class? I'm against making logger a stand alone class becouse it increases dependencies. But maybe I'm not right, in the end, loggers global inteface won't probably change.


Why not just use the standard output streams. No dependencies on anything other than the stl which is not likely to change? Log with cout, clog or cerr. Create your own overloads of the << operator for debugging purposes.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!