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*

12
  • 1
    But be aware! Use Your Singletons Wisely: ibm.com/developerworks/webservices/library/co-single.html Commented Apr 21, 2009 at 14:06
  • See also: stackoverflow.com/questions/137975/… Commented Apr 21, 2009 at 14:13
  • 1
    A logger is one of the few places that a singleton is a good choice! Commented Apr 21, 2009 at 15:06
  • 1
    No. Why did this get accepted? Singletons and globals are completely different things. If you need something to be global, make it global. But making something global does not mean that it should also be limited to one instance. By the way, a logger is not a good place for a singleton either. I've thought so before, and then a few months later, cursed as I had to add a second logger after all. It saves so much work to just not make it a singleton in the first place. Commented Apr 21, 2009 at 16:24
  • It's not a global variable, but it gets around having to use a global with a bunch of externs. I wasn't suggesting for him to change his code to have only 1 logger in the first place, that's already present in his code. But it is a more object oriented way then he is currently using. As of right now he has a single one anyway. I also provided the 2 warning links about when not to use it. Commented Apr 21, 2009 at 16:39