Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualSimonForsman

Posted 09 May 2013 - 01:01 PM

A basic philosophy I sort of follow is that code should be (in order):


  • As optimized as necessary.
  • Simple
  • Transparent
Singletons usually fail on the transparency case, but they're worth using if the alternative has huge code complexity costs.


a global instance of a normal class is less complex than a singleton and more flexible.

Singletons are just a global with a "there can be only one" restriction and some makeup, If you don't absolutely need to restrict the number of instances to 1, just use a global(put it in a sane namespace), using singletons because "globals are evil" is silly since a singleton is a global. (and globals are only really evil if their state can be modified globally, stateless functions, constants, etc are perfectly fine to allow global access to).

#1SimonForsman

Posted 09 May 2013 - 12:53 PM

A basic philosophy I sort of follow is that code should be (in order):


  • As optimized as necessary.
  • Simple
  • Transparent
Singletons usually fail on the transparency case, but they're worth using if the alternative has huge code complexity costs.


a global instance of a normal class is less complex than a singleton and more flexible.

Singletons are just a global with a "there can be only one" restriction and some makeup, If you don't absolutely need to restrict the number of instances to 1, just use a global, using singletons because "globals are evil" is silly since a singleton is a global.

PARTNERS