Do(‘nt) use the Singleton Design Pattern!?

What is the singleton design pattern and how does it work?
The Singleton Design Pattern is described in the legendary book “Design Patterns” by the Gang of Four.

A Singleton takes itself care of  t’s instantiation and life cycle. Because the constructor is not public, it is not possible to create an object outside of the class.
Therefore it has a static method (i.e. getInstance) as global access point. It has also a private static attribute of itself, that is only instantiated one time. This way the instance method returns always the same instance.

When or why could you apply this Design Patterns?
A Singleton is used, when you want to make sure, that there’s only one Instance of a class. Continue reading “Do(‘nt) use the Singleton Design Pattern!?”