Design Patterns in C#
September, 2018 / by Krishan Dutt Sharma
What is design Pattern in c#?
Design Patterns are categorized into 3 types and they are:
- Creational Design Patterns.
- Structural Design Patterns.
- Behavioral Design Patterns.
What are Creational Design Patterns?
These patterns deal with the process of objects creation. The flowing is the different types of Creational Design patterns.
- Abstract Factory Pattern - Create instances of several classes belonging to different families.
- Factory Pattern - Create instances of derived classes.
- Builder Pattern - Separates an object construction from its representation.
- Lazy Pattern - Create a duplicate objector clone of the object.
- Prototype Pattern - Specify the kind of objects to create using a prototypical instance, and create new objects by copying this prototype.
- Singleton Pattern - Ensures that a class can have only one instance.
What are Structural Design Patterns?
These patterns deal with the composition of objects structures. The flowing is the different types of Structural Design patterns.
- Adapter Pattern - Interfaces of classes vary depending on the requirement.
- Bridge Pattern - Class level abstractions separated from its implementation.
- Composite Pattern - Individual objects &a group of objects are treated similarly in this approach.
- Decorator Pattern - Functionality is assigned to an object.
- Facade Pattern - A common interface is created for a group of interfaces sharing a similarity.
- Flyweight Pattern - The concept of sharing a group of small-sized objects.
- Proxy Pattern - When an object is complex and needs to be shared, its copies are made. These copies are called the proxy objects.
What are Behavioral Design Patterns?
These patterns deal with the process of communication, managing relationships, and responsibilities between objects. The flowing is the different types of Behavioral Design patterns.
- Chain Or Responsibilities Pattern - In this pattern, objects communicate with each other depending on logical decisions made by a class.
- Command Pattern - In this pattern, objects encapsulate methods and the parameters passed to them.
- Observer Pattern - Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
- Interpreter Pattern - A way to include language elements in a program.
- Iterator Pattern - Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.
- Mediator Pattern - Define an object that encapsulates how a set of objects interact. In other words, it defines simplified communication between classes.
- Memento Pattern - Without violating encapsulation, capture and externalize an object's internal state so that the object can be restored to this state later.
- State Pattern - Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.
- Strategy Pattern - Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
- Visitor Pattern - Defines a new operation to a class without change.
- Template Method Pattern - Defer the exact steps of an algorithm to a subclass.