Saturday, 21 May 2011

Design Patterns


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.
  1. Creational
  2. Behavioral
  3. Structural
    1. Creational
      Concerned about ways to create new objects.  
    2. Behavioral
      Concerned about ways in which objects interacted  
    3. Strucural
      Concerned about the composition of objects and classes
Creational Patterns
SingletonTo Create a sole instance of a class
PrototypeTo create object by cloning existing object.
BuilderBuild an object from existing representation
Factory MethodDefer instantiation to subclass
Abstract FactoryProvides interface to create families of objects without specifying the concrete classes of the objects
Structural Patterns
AdapterConvert an instance to another
CompositeComposite objects in a tree structure
DecoratorAttach additional responsibilities dynamically
ProxyProvide a surrogate or placeholder for another object
Fa├žadeProvide a unified instance to a set of instances in sub system
BridgeDecouple abstraction from implementation. Let them vary and independent.
FlyweightA fine-grained instance user for efficient sharing
Behavioral Pattern
Chain of Resp.Delegates commands to a chain of processing objects.
CommandCreates objects which encapsulate actions and parameters.
InterpreterImplements a specialized language.
IteratorAccesses the elements of an object sequentially without exposing its underlying representation.
MediatorAllows loose coupling between classes by being the only class that has detailed knowledge of their methods.
MementoProvides the ability to restore an object to its previous state (undo).
ObserverPublish/subscribe pattern which allows a number of observer objects to see an event.
StateAllows an object to alter its behavior when it's internal state changes.
StrategyAllows one of a family of algorithms to be selected on-the-fly at runtime.
Template MethodDefines the skeleton of an algorithm as an abstract class, allowing its subclasses to provide concrete behavior.
VisitorSeparates 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

No comments:

Post a Comment