In favor of the singleton
A short and very enjoyable read by Uncle Bob on singletons:
Do you recognize this: ``` public class X { private static X instance = null;private X() {}
public static X instance() { if (instance == null) instance = new X(); return instance; }
// more methods... }
<em>Of course. That's the Singleton pattern from the GOF book. I've always heard we shouldn't use it.</em> Why shouldn't we use it? <em>Because it makes our systems hard to test.</em> It does? Why is that? ....</blockquote> You can read the whole conversation on <a href="http://blog.cleancoder.com/uncle-bob/2015/07/01/TheLittleSingleton.html">http://blog.cleancoder.com/uncle-bob/2015/07/01/TheLittleSingleton.html</a>
What are your thoughts on "In favor of the singleton"?