I am starting to write articles on design patterns. We have 3 types of design patterns as per GoF. There are plenty of design patterns available but 23 standard pattern I am going to cover in my article. Design patterns are Solutions to commonly occurring design problem. Someone has already faced the problem and come up with good and elegant solution. The same pattern you have to use. Design Pattern divided into 3 categories.
- Creational
- Behavioral
- Structural
- CreationalConcerned about ways to create new objects.
- BehavioralConcerned about ways in which objects interacted
- StrucuralConcerned about the composition of objects and classes
Singleton | To Create a sole instance of a class |
Prototype | To create object by cloning existing object. |
Builder | Build an object from existing representation |
Factory Method | Defer instantiation to subclass |
Abstract Factory | Provides interface to create families of objects without specifying the concrete classes of the objects |
Adapter | Convert an instance to another |
Composite | Composite objects in a tree structure |
Decorator | Attach additional responsibilities dynamically |
Proxy | Provide a surrogate or placeholder for another object |
Façade | Provide a unified instance to a set of instances in sub system |
Bridge | Decouple abstraction from implementation. Let them vary and independent. |
Flyweight | A fine-grained instance user for efficient sharing |
Chain of Resp. | Delegates commands to a chain of processing objects. |
Command | Creates objects which encapsulate actions and parameters. |
Interpreter | Implements a specialized language. |
Iterator | Accesses the elements of an object sequentially without exposing its underlying representation. |
Mediator | Allows loose coupling between classes by being the only class that has detailed knowledge of their methods. |
Memento | Provides the ability to restore an object to its previous state (undo). |
Observer | Publish/subscribe pattern which allows a number of observer objects to see an event. |
State | Allows an object to alter its behavior when it's internal state changes. |
Strategy | Allows one of a family of algorithms to be selected on-the-fly at runtime. |
Template Method | Defines the skeleton of an algorithm as an abstract class, allowing its subclasses to provide concrete behavior. |
Visitor | Separates an algorithm from an object structure by moving the hierarchy of methods into one object. |
Reference Books
C# 3.0 Design Patterns
Design Patterns in C#
C# 3.0 Design Patterns
Agile Principles, Patterns, and Practices in C#
Pro .NET 4 Parallel Programming in C# (Expert's Voice in .NET)
C# Design Patterns: A Tutorial