|
||||||||||||||||||
Add Forum to Favorites | Send Topic To a Friend | View Forum FAQ | Track this topic |
Last Thread Next Thread ![]() |
| Using Managers |
|
![]() Redleaf Member since: 5/31/2000 From: Rochester, NY, United States |
||||
|
|
||||
| Nice ideas, and indeed the concept is sound. Code that only has to be written once is always a good thing, and I've made my own resource managers on the same premise. There are a few points that could be improved, however. One thing you might want to consider instead of the use of pointers explicitly to ID your resources is to load resources by name. Simply a string, which could be a filename, used for identification. I find this much more intuitive, and later on when creating resources which depend on other resources, it's much easier to reference these other resources by their name, given this capability. The second point is to use some sort of hash, or a map (such as that found in the STL) to allow a generally faster search for a resource that's already present. This applies to any identification method you choose, by the way. The third point is arguable. Do you really need to enforce the singleton nature of a manager? I would think there are better ways to design around this. Still, nice concise article. "Don't be afraid to dream, for out of such fragile things come miracles." |
||||
|
||||
![]() Ecko Member since: 9/7/2000 From: Etiwanda, USA!!!!!!! |
||||
|
|
||||
| This article was very good, but I find myself using 2 different managers with the same types of objects (ie enemy players and friendly players). A good way around this is to make the Base class the singleton instead of creating a manager singleton that then is inherited. But there are always exceptions to the rule. -ecko |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| This article is hilarious... it embodies so much about how to NOT write code in one article, while still misleadingly looking like a valid tip... I couldn't have done it better. Reference counting a singleton object? genius! |
||||
|
||||
![]() gamejunkie Member since: 3/16/2002 From: USA |
||||
|
|
||||
| DIdn't I see something awful similar to this in the Game Programming Gems series??? Hmmmm.... With regard to the previous post, I believe he is reference counting the objects the manager class is managing, not the singleton manager itself. |
||||
|
||||
![]() fooman Member since: 4/16/2004 |
||||
|
|
||||
| Well, the way you built up your singleton is not estetic, because the least thing you should do is to inline your functions to prevent sensless stackusing. However, a singleclass solution would be better. Also the refcount is a little anoying, becaus ein a multithreaded app it often happens, that at a moment ref count is set to 0, but the data in your manager is needed in the next function or whatever. Also pointing out, that in many cases the use of a linked or doublelinked list has advanteges, such as dynamic arraysize. I would accept it if it was a very simple examplecode, but you build up nearly your entire article on this code. cYa fooman |
||||
|
||||
All times are ET (US)![]() |
Last Thread Next Thread ![]() |
|