Overview: Singleton Design Pattern is a creational design pattern that ensure that a class has only one instance while providing a global access point to this instance.
Creational Design Patterns are a design pattern that deal with object creation mechanisms.
When to use Singleton Design Pattern
- If you have resources which are shared amongst the entire application such as a databases or a file
How to implement

- Define a private
staticattribute in the “single instance” class - Define a public
staticaccessor function in the class - Do “lazy initialization” (creation on first use) in the accessor function
- Define all constructors to be
protectedorprivate - Clients may only use the accessor function to manipulate the Singleton
REFERENCE:https://sourcemaking.com/design_patterns/singleton