# Introduction to C# Design Patterns

**Design Patterns** are nothing but documented and tested solutions for recurring problems in a given context. So, in simple words, we can say that Design Patterns in the object-oriented world is a reusable solution to common software design problems that occur repeatedly in real-world application development.

The book **Elements of Reusable Object-Oriented Software** written by the authors named as **Gang of Four** brought the concepts of design patterns.

![Design Patterns In DotNet.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1631426819036/qj2sdQJps.jpeg)

These patterns are generally considered as the foundation for all other patterns. They categorized the patterns into three categories based on the three problem areas. They are:


**1. Creational Design Patterns:** It gives the programmer more flexibility in deciding which objects need to be created for a given case. The Creational Design Patterns are:

- Factory Method (Create objects without exposing the creation logic)
- Abstract Factory (Helps to control the classes of objects that an application creates)
- Builder (Separate the construction of a complex object)
- Prototype (Create a duplicate object)
- Singleton (Allows only one instance to be created)

**Structural Design Patterns:** Basically used to manage the structure of classes and interface as well as manage the relationship between the classes. The Structural Design Patterns are:

- Adapter (Allows incompatible interfaces to work together)
- Bridge (Divides business logic or huge classes)
- Composite (Composes objects in term of a tree structure)
- Decorator (Allow to add new functionality to an existing object without altering its structure)
- Façade (Provides simple interface into complex system)
- Flyweight (Share existing objects to consume less memory)
- Proxy (Provide a substitute or placeholder for another object)

**Behavioral Design Patterns:** This patterns are concerned with algorithms and the assignment of responsibilities between objects. In these design patterns, the interaction between the objects should be in such a way that they can easily talk to each other and still should be loosely coupled. The Behavioral Design Patterns are:

- Chain of Responsibility (Creates a chain of receiver objects for a given request)
- Command (Encapsulate a request as an object and pass to an invoker)
- Interpreter (Specifies how to evaluate sentences in a language)
- Iterator (Access and manipulate objects in a collection without exposing)
- Mediator (Reduces coupling between components)
- Memento (Provide an undo or rollback capability in an application)
- Observer (Define a one-to-many dependency between objects)
- State (Allows an object to alter its behavior when its internal state changes)
- Strategy (Enables selecting an algorithm at runtime)
- Visitor (Allows to modify existing instances of objects without modifying the class)
- Template Method (Enables algorithms to defer certain steps to subclasses)

Design Patterns offer answers to questions that most software developers face regardless of the size or scope of the project. Through this article I tried to share the summarize some of them. Along with GoF 23 Design Patterns, there are some other mostly used design patterns, like: Dependency Injection Design Pattern, Repository Design Pattern, Inversion of Control etc. Hopefully we'll discuss them in near future.
