News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Mike Lively's Blog:
Why I Hate Singletons
December 29, 2008 @ 12:05:45

Mike Lively has posted a few choice words about one of the most popular and most used design patterns out there - the Singleton.

One of the most derided, yet most loved and used patterns is the singleton pattern. Its supporters continually praise its ability to limit instantiation of objects and its opponents continually chastise its tendency to be little more than a glorified global. While programming in many ways boils down to a matter of preference (you can always find someone that agrees with you,) I thought I might as well document my opinion so that those who don't care can have one more thing to ignore.

He starts by (correctly) defining a Singleton and why, because of that definition, they are evil - they become a "global point of access". Why is that such a bad thing, you ask? Mike By their design they mask dependencies, making it harder to do future development and/or maintenance.

I personally do not see very many viable uses for singletons and I know there are many people that agree with me (google evil singletons). It's simplicity seems appealing, but they are incredibly easy to use in a damaging way. This is the danger you risk with any concept that is easy to understand and easy to abuse.
0 comments voice your opinion now!
singleton evil dependency opinion global access point


blog comments powered by Disqus

Similar Posts

Juozas Kaziukenas' Blog: Why Zend Framework?

Nodeable Blog: Marten Mickos: The LAMP Stack is Dead, and Cloud has Killed It

Richard Thomas' Blog: ZF please before you go 2.0 gunho please clean out the attic

Anthony Ferrara: An Opinion On The Future Of PHP

Kevin Schroeder's Blog: How chickens and programming are kind of related


Community Events





Don't see your event here?
Let us know!


code laravel bugfix api configure project series list wordpress framework interview release introduction threedevsandamaybe community library application podcast developer language

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework