The Creational Design Pattern are Categorized into two types.
- Object-Creational Patterns: Object -Creational Patterns deal with object creation. Here, it defers part of its object creation to another object.
- Class-Creational Patterns:Class-Creational Patterns deal with class Instantiation. Here, it defers its object creation to subclasses.
In real-time applications, the project is created with a lot of classes. A lot of classes mean we are dealing with a lot of objects. So, we need to create different objects for an ECommerce Application. If the object creation logic based on some condition is implemented in the client code, then it leads to lots of complicated logic in the client code.
That means if the object creation and initialization logic are not centralized, then it leads to a very complicated client code.The creational design pattern help us to centralize the object creation and initialization logic and depending upon the condition, it wil create, initialize, and returns the approciatte object to the client,and then teh client can consume the object by calling the necessary method and properties.
Creational Desgin Pattern IN C#:
- Factory Design Pattern: A factory is an object which is used for creating other objects.The Factory Method Design Pattern defines an interface for creating an object, but let the subclasses decide which class to instantiate, This pattern let a class defer instantiation to subclasses.
- Abstract Factory Design Pattern: The Abstract Factory Design Pattern provides a way to encapsualte a group of individual factories that have a common theme without specifying their concrete classes.
- Single Design Pattern: The Singleton Design Pattern ensures a class has only one instance and provide a global point of access to it.
- Builder Design Pattern: The Builder Design Pattern separates the construction of a complex object from its representation so that the same construction process can create diferrent representations.
- Fluent Interface Design Pattern: The Fluent interfaces and Method Chaining are related to each other. Or we can say that one is a concept and the other one is implementation.The main objective of the Fluent Interface Design Pattern is that we can apply multiple properties(or methods) to an object by connecting them with dots(.) without having to re-specify the object name each time.
- Prototype Design Pattern: The prototyp design pattern specifies the kind of objects to create using a prototypical instance, and create new objects by copying this prototype.