Singletons are not inherently globally available/changeable(at least no more than any other local variable)
SINGLETONS is just a desing pattern, you could store it globally, but that does not mean singletons are bad, just the programmer.
a physics engine in a game is a singleton design, you cant change the physics from the NPC class (unless you THE PROGRAMMER provide that functionality).
Is this a good programming practice
Moderator: Coders of Rage
Re: Is this a good programming practice
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
Dad, "Yea well I have a fan belt in street fighting"
Re: Is this a good programming practice
The general argument against Singletons is that there isn't any real reason to have restriction the 'can only create one instance' by design because in theory there are very few scenarios where it must be enforced by design. For example, you may have more then one physics world instance if you have an odd multi-player mode. If you used a legacy framework or library which had the physics world class as a singleton, it would mean that you have to to some refractoring of that class any any others that relied on this fact whereas it could have originally been simply a local instance of the class without the design restriction of a singleton.
Offtopic: I be weary of using malloc to allocate memory for a class as it doesn't call the class's constructor whereas new does.
Offtopic: I be weary of using malloc to allocate memory for a class as it doesn't call the class's constructor whereas new does.