From a programmer's perspective, we use creational design patterns when we perform object creation. Patterns are selected based on the task at hand. There are five creational design patterns:
- Singleton: The singleton pattern ensures that only one instance of an object will exist at the application level.
- Factory method:A factory pattern is used to create objects without using the class to be used.
- Abstract factory: Without the specification of their concrete classes, groups of related or dependentobjects are instantiated by the abstract factory.
- Prototype: Specifies the type of prototype to create, and then creates copies of the prototype.
- Builder: Separates object construction from its representation.
We will now begin implementing each of these patterns, starting with the singleton design pattern.
Implementing the singleton pattern
The singleton...