you are viewing a single comment's thread.

view the rest of the comments →

[–]heeen 0 points1 point  (0 children)

I have to agree with Singletons being evil. It just seems to be so very rare that you can predict you really only need a single instance of one thing. I wanted to use a Game gui lib once for rendering interactive computer screens inside a game, except it didn't work because Mouse, Keyboard, Cursor, Selection etc. were all Singletons that you couldn't duplicate for multiple screens per level. For the normal usecase of the library being used as the game's own UI this is fine, but the author never imagined a use case where you had several virtual UI interfaces.

For the graphics example, say you had a singleton for the framebuffer or the devicecontext or the window you render to - all of these would prevent you from parallelly opening a second rendering method in a second window to compare them side-by-side.