Design Patterns in C#

What is design Pattern in c#?

Design Patterns are categorized into 3 types and they are:

  1. Creational Design Patterns.
  2. Structural Design Patterns.
  3. Behavioral Design Patterns.

What are Creational Design Patterns?

These patterns deal with the process of objects creation. The flowing are the different types of Creational Design patterns.

  1. Abstract Factory Pattern: - Create instances of several classes belonging to different families.
  2. Factory Pattern: - Create instances of derived classes.
  3. Builder Pattern: - Separates an object construction from its representation.
  4. Lazy Pattern: - Create a duplicate object or clone of the object.
  5. Prototype Pattern: - Specify the kind of objects to create using a prototypical instance, and create new objects by copying this prototype.
  6. 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 are the different types of Structural Design patterns.

  1. Adapter Pattern: - Interfaces of classes vary depending on the requirement.
  2. Bridge Pattern: - Class level abstraction is separated from its implementation.
  3. Composite Pattern: - Individual objects & a group of objects are treated similarly in this approach.
  4. Decorator Pattern: - Functionality is assigned to an object.
  5. Facade Pattern: - A common interface is created for a group of interfaces sharing a similarity.
  6. Flyweight Pattern: - The concept of sharing a group of small sized objects.
  7. 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 are the different types of Behavioral Design patterns.

  1. Chain Or Responsibilities Pattern: - In this pattern, objects communicate with each other depending on logical decisions made by a class.
  2. Command Pattern: - In this pattern, objects encapsulate methods and the parameters passed to them.
  3. 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.
  4. Interpreter Pattern: - A way to include language elements in a program.
  5. Iterator Pattern: - Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.
  6. Mediator Pattern: - Define an object that encapsulates how a set of objects interact. In other words, it defines simplified communication between classes.
  7. Memento Pattern: - Without violating encapsulation, capture and externalize an object's internal state so that the object can be restored to this state later.
  8. State Pattern: - Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.
  9. 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.
  10. Visitor Pattern: - Defines a new operation to a class without change.
  11. Template Method Pattern: - Defer the exact steps of an algorithm to a subclass.
Ebook Download
View all
Learn
View all