ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Using the Singleton Pattern
Subject:   Singleton Considered Harmful
Date:   2003-08-29 11:37:24
From:   jimothy
Response to: Singleton Considered Harmful

Thanks for the links. The first link (SingletonsAreEvil) linked me to an IBM developerWorks article, which it turns out I had previously read before, and formed much of the basis for what I wrote in my post.


It's a good article that explains the pitfalls of singletons, how to structure your code to avoid using singletons, and the benefits of doing so. I recommend everyone who read this O'Reilly article also take a look at a counterpoint: http://www-106.ibm.com/developerworks/webservices/library/co-single.html


My advice is not to use any pattern blindly; the GoF describes the appropriate contexts and forces for using a particular pattern. The Singleton pattern is especially easy to abuse, because it is so simple conceptually. But no pattern should be taken as the Gospel.