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*

3
  • 6
    You can still have lazy initialization with a "global" object using an accessor. Many people mistake "I only want one" with "only one should ever be allowed". There's no need to harm your not-a-singleton class' testability if you don't need to. Commented Jan 16, 2011 at 19:25
  • Normally I implement a "normal" class and subclass a singleton-version of it, because I can't predict if I need new instances in the futur or not Commented Oct 22, 2012 at 14:32
  • "Anything that uses the singleton is now tightly coupled to it" is just not true. It's only true "Most things that use the singleton do tight coupling" and so the bad part about it isn't the singleton, but how people use and abuse it. Just like with global vars. programmers.stackexchange.com/a/218322/4261 Commented Nov 13, 2013 at 15:30