Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
References for Why Not to Use Singleton Design Pattern
http://www.youtube.com/watch?v=-FRm3VPhseI Google's Clean Code Talks
http://blog.gordon-oheim.biz/2011-01-17-Why-Singletons-have-no-use-in-PHP/
http://sebastian-bergmann.de/archives/882-Testing-Code-That-Uses-Singletons.html
http://eamann.com/tech/making-singletons-safe-in-php/
http://hakre.wordpress.com/2012/06/10/the-missing-patterns-of-the-php-manual/#p2
http://blogs.msdn.com/b/scottdensmore/archive/2004/05/25/140827.aspx
http://www.phptherightway.com/pages/Design-Patterns.html ("You should be wary when using the singleton pattern, as by its very nature it introduces global state into your application, reducing testability.")
http://www.practicaldesignpatternsinphp.com/ ("The Singleton Pattern is perhaps the most well known - and most often misused - pattern in all of PHP design pattern development. Its simplicity, combined with its seeming benefits makes it a widely-used (and overused) pattern. The Singleton is not so much a recommended pattern, as a pattern I recommend you shy away from.")
http://www.slideshare.net/go_oh/singletons-in-php-why-they-are-bad-and-how-you-can-eliminate-them-from-your-applications
http://en.wikipedia.org/wiki/Singleton_pattern
http://i.stack.imgur.com/Dzdio.png
Once you've read all those, read everything abou Dependency Injection, how that helps with injecting mocks during unit testing, and therefore why Singletons are bad.
@schlessera

This comment has been minimized.

Copy link

schlessera commented Nov 14, 2016

Why aren't these links clickable? Links that are not clickable are like music without a sound, remaining bleak and lifeless, and forever hiding their true purpose.

@rcstr

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.