Jump to content
  • Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

928 Good

About Illco

  • Rank
  1. Illco

    Singletonitis, Part 2

    Maybe I am missing some important point here and if so then please tell me, but in my opinion most of the arguments in this article are false. Quote: Argument: the singleton pattern makes the class globally visible which pollutes the global namespace. Why must a singleton be in the global namespace whereas other objects do not have to be? A singleton is as globally available as any other type. Quote: Argument: the programmer cannot guarantee that multiple instances are created. Not true. If the constructor is inaccessible and the GetInstance() function returns only the same instance, it is guaranteed that only one instance exists. The only glitch is thread safety which goes for all functions. Quote: Argument: global access is only waranted for classes that are used in a great part of code. This means that whenever the size of code change, a smaller portion may be using the singleton. So when writing many lines of non-singleton code, suddenly the singleton is no longer warranted? What about future use of the singleton class in this or other projects? Quote: Argument: anyone can change the state of an object making it intractible. This goes for any object. As long as the member functions are safe in this sense the state of the object is secured. Again maybe I am totally besides some point here. And now its time to really duck for me too I guess. ;-) Greetz, Illco PS: quotes are not literally but an extraction made by me
  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!