Singleton pattern deals with ensuring that there is only one instance of
a class and providing a single global access point to that object. It
also ensures that the object is not created until its actually needed.
As you can see from the above example the 2 instances of the
SingletonPerson object are the same and so are their properties viz.
Name, Age and Address. We can use the singleton pattern when we need to
create only one instance of a class or when we need to provide
controlled access to an instance.
In my next post I will be writing about the Abstract Factory Pattern.