"Provide object creation mechanism"
Creational Design Patterns are concerned with the way in which objects are created.
Creational Design Patterns address this issue by decoupling the client entirely from the actual initialization process.
Difficult to understand right?
In simpler terms, sometimes its important to be flexible with the nature of your object. When its required that the nature of the object must be changed according to the nature of the program. In such cases, creational design patterns come in handy to provide more general and flexible approach to object creation.
In other words, the general way of object creation could result in design problems or added complexity to the design and to prevent this we use Creational Design Patterns.
Well if your aim resonates with any of the below scenario,
- You want at most only one instance of an object available throughout the application. eg. Service classes should be stateless, and hence they don't need more than one instance.
- If you want to create objects of several related different classes and you do not want to specify which object is created and also you do not want to coupled your code to use one class so that if later you introduce another class, this would require to make change in the entire codebase.
More such scenarios exist however the intake should be that if you want your code less coupled in terms on initialization and reduce complexities and instability by creating objects in a controlled manner, maybe creational pattern can come to the rescue.
We will be discussing about 5 of the commonly used Creational design Patterns namely,
- Singleton Pattern
- Factory Pattern
- Abstract Factory Pattern
- Builder Pattern
- Prototype Pattern
We will be discussing about above mentioned patterns in the upcoming posts starting with Singleton Pattern.
Note - Be part of the discussion and also leave a heart if you found it helpful.