Hey,
I have a question i could not solve on my own and that is : i heard everywhere to avoid using singletons BUT there is no need for more then 1 irrlicht device...
So in the case of the irrlicht device...isn't using singleton a better idea or not?
and why?
Singleton with irrlicht device?
-
- Posts: 212
- Joined: Sun Jul 19, 2009 4:24 am
- Location: Netherlands Antilles, Curacao
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
Re: Singleton with irrlicht device?
Using singletons is a good design decision in general. So yes, use singletons where they are appropriate.
"Whoops..."
You might need more than one Irrlicht device, at least in theory, say having 2 windows with 2 different configurations (if that is possible nowadays).
Singletons IMHO is for things that is never needed to be instantiated more than once (well, I learn you nothing here) so say the file system of irrlicht could be one.
I never really understood why people don't like singletons (when as randomMesh said, used where appropriate).
Singletons IMHO is for things that is never needed to be instantiated more than once (well, I learn you nothing here) so say the file system of irrlicht could be one.
I never really understood why people don't like singletons (when as randomMesh said, used where appropriate).
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Singletons are also using a very special access scheme. The static method is rather API-disrupting and often not necessary. E.g. the filesystem in Irrlicht is not user constructable, because there's no public API function for it. However, we can also avoid the static method, as we can pass the pointer to the filesystem instead. IMHO singleton is seldomly fitting.