Whether it is attacked as an anti-pattern, malignedas untestable, or misused as a global convenience, singletons take a lot of 💩 for just being what they are: a way to enforce that there is only ever one of something. I think they should call this pattern “The One”.
A real life example of a singleton is The President of the United States. We only ever have one president at a time. That’s a key part of the concept. It’s not just a convenience.
A technical pet peeve of mine, this post does a nice job articulating why “manager” classes in software design can be a problem. To me, a “manager” class is like saying, “this class does some stuff” and the stuff has no boundary. But what does this class do? What is it’s purpose? It might be a sign of an unfocused and unsustainable design.
Or as the post says:
Managers can be a symptom of poorly-defined responsibilities. When you think about it, the word “Manager” means nothing. In object oriented programming,everyclass is a manager. Cocoa Touch could haveUIApplicationManager,UIViewManager, and even a humbleNSStringManager.