Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • 'Singletons are good design practice because you can always modify global object somewhere, or someone else can just overwrite it. Not possible with singleton pattern.' ?? Could you clarify the difference between 'singleton' and 'singleton pattern'? Commented Jan 16, 2011 at 20:19
  • Hm... singleton is a concept or something you can use and singleton pattern is how you'll make that concept work. Commented Jan 16, 2011 at 20:24
  • 3
    Singletons only fix small problems with global variables. Global variables encourage coupling which ideally we'd like to prevent. The technique of using singletons does nothing to help there. The complaint against singletons is basically that people convert a global variable into a singleton and think all is good. But really they've only fixed relatively minor issues that come from using globals. Commented Jan 16, 2011 at 20:55
  • 2
    Regarding Math, that's not a singleton its a static class. There is no problem with static/global functions as long as those functions as long as they are stateless. Commented Jan 16, 2011 at 21:00
  • 1
    You might also examine some large open source "C" based projects for a solid example of how to handle logging etc w/o a singleton pattern. Apache, for one. Even in an OOP system, if you litter your code with what is basically a global object, then you are tightly coupling your code (bad OOP) and making unit testing a nightmare. Commented Jan 17, 2011 at 13:27