This is one of the favorite questions asked by interviewers.
I thought of putting my opinions on this topic.
- Most important singletons can be handled polymorphically without forcing their users to assume that there is only one instance.
- Singletons can implement interfaces (or derive from useful base classes).
- Singleton class follow the object oriented principles but not static class.
- A singleton can be initialized lazily or asynchronously while a static class is generally initialized when it is first loaded, leading to potential class loader issues.
My rule for choosing between static and singleton:
If there are bunch of functions should be kept together, then static is the choice.
Anything else which needs single access to some resources, could be implemented singleton.