Design Patterns in .NET

Introduction

Design patterns are recurring solutions to software design problems you find again and again in real-world application development. Patterns are about design and interaction of objects, as well as providing a communication platform concerning elegant, reusable solutions to commonly encountered programming challenges

There are so many design patterns available for Software application development, depending upon your need and domain you are working on.  

First thing, Why we need design patterns?. Everyone asks this, since all of them are interested in RAD (Rapid Application Development).  When you do that, did you find yourself messed up somewhere in the logics of Code. We want to develop industrial standardized code, which would provide us Ease of Development efforts, Reusability, and could be able to target on multiple domains. That’s why we are opting design patterns.

More over each developer has their own coding style, Developer-A has written some logic of his own, Developer-B has their own, like that whole team is developing code based on what their mind tells. When Developer-E and F are trying to understand the code, do maintenance of the code they will get stuck by unable to understand the code the other team mates have written. That’s what happens when you didn’t follow a pattern.

We need a unified structure that helps us to understand and maintain the code easily. So that our efforts on development, bug fix are reduced. That’s why we are opting design patterns.

The book Design Patterns: Elements of Reusable Object-Oriented Software by ErichGamma, RichardHelm, RalphJohnson, and JohnVlissides (the GangOfFour), is known as the Gang of Four.

The Gang of Four (GoF) patterns are generally considered the foundation for all other patterns.

They are categorized in three groups: Creational, Structural, and Behavioral. Here you will find information on these important patterns. 

 Creational Patterns
  Abstract Factory   Creates an instance of several families of classes
  Builder   Separates object construction from its representation
  Factory Method   Creates an instance of several derived classes
  Prototype   A fully initialized instance to be copied or cloned
  Singleton   A class of which only a single instance can exist

 

  Structural Patterns
  Adapter   Match interfaces of different classes
  Bridge   Separates an object’s interface from its implementation
  Composite   A tree structure of simple and composite objects
  Decorator   Add responsibilities to objects dynamically
  Facade   A single class that represents an entire subsystem
  Flyweight   A fine-grained instance used for efficient sharing
  Proxy   An object representing another object

 

  Behavioral Patterns
  Chain of Resp.   A way of passing a request between a chain of objects
  Command   Encapsulate a command request as an object
  Interpreter   A way to include language elements in a program
  Iterator   Sequentially access the elements of a collection
  Mediator   Defines simplified communication between classes
  Memento   Capture and restore an object’s internal state
  Observer   A way of notifying change to a number of classes
  State   Alter an object’s behavior when its state changes
  Strategy   Encapsulates an algorithm inside a class
  Template Method   Defer the exact steps of an algorithm to a subclass
  Visitor   Defines a new operation to a class without change

 

Summary

Design patterns are recurring solutions to software design problems you find again and again in real-world application development. Patterns are about design and interaction of objects, as well as providing a communication platform concerning elegant, reusable solutions to commonly encountered programming challenges.

Design Patterns are a unified programming models implemented on a Team Project. Where entire team follows a single structure of application development. Helps the Team to maintain/manage their development efforts in  a proper way.

This article describes Design Patterns in a Brief. Individual Patterns with Examples and Real World Implementations would be explained in individual articles later.

Stay tuned. More to Come… 

About Author

Nithin Mohan T K is a software enthusiast working for Tecra Systems Inc, Hyderabad having  4+ years of experience in .NET Application development. He is a Microsoft Certified Professional Developer on Web and Enterprise App. Contributing the knowledge for the use of mankind that’s his Moto.

References