Software Design Patterns - .Net


Software Design Patterns - .Net

In short "Design Patterns are recurring solution to recurring problems in software architecture."

What are Design Patterns - C#

Software Design Patterns are about reusable designs, interaction of objects and high quality solution to a given requirement, task or recurring problem. So .Net Design Patterns are documented tried and tested solutions or recurring problems in a give context. They are reliable and they speed up software development process.

Example : A windows based banking applications are usually based on singleton pattern, e-commerce web applications are based on the MVC (Model-View-Controller) pattern etc.

design patterns, design patterns c#,software design patterns, template design pattern, gang of four design patterns, object oriented design patterns, factory design pattern,
Software Design Patterns

What are 3 Types of Design Patterns

Design patterns are divided into three problem areas :

Creational Patterns
Creational patterns are used to create objects for a suitable class that serves as a solution for a problem. Generally when instances of several different classes are available. They are particularly useful when you are taking advantage of polymorphism and need to choose between different classes at runtime rather than compile time. 

For example if your creational objects are not centralized it will be a very complicated code. Creational pattern helps us to centrealize these object creational process in one class and thus minimizing the complected logic as the client code. There are following basic classification of 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 in which only a single instance can exist
Behavioral Patterns
Behavioral patterns describe interactions between objects. They focus on how objects communicate with each other. They can reduce complex flow charts to mere interconnections between objects of various classes. "Sometimes you want to change the behavior of a class but you don't want that again to affect the other classes in the project, there behavioral pattern helps us."

Behavioral patterns are also used to make the algorithm that a class uses simply another parameter that is adjustable at run-time. For example we use template design pattern. Template method is the simpler and more common of the two. There are following basic classification of behavioral patterns :
  • Mediator - Defines simplified communication between classes.
  • Memento - Capture and restore an object's internal state.
  • Interpreter - A way to include language elements in a program.
  • Iterator - Sequentially access the elements of a collection.
  • Chain of Resp - A way of passing a request between a chain of objects.
  • Command - Encapsulate a command request as an object.
  • State - Alter an object's behavior when its state changes.
  • Strategy - Encapsulates an algorithm inside a class.
  • Observer - A way of notifying change to a number of classes.
  • Template Method - Defer the exact steps of an algorithm to a subclass.
  • Visitor - Defines a new operation to a class without change.
Structural Patterns
Structural patterns are concerned with how classes and objects are composed to form larger structures. Structural class patterns use inheritance to compose interfaces or implementations. "Sometimes you would like to change the structure of the classes or we can say the relationship between classes but you don't want to the project get to affected, there structural pattern helps us."

As a simple example, consider how multiple inheritance mixes two or more classes into one. The result is a class that combines the properties of its parent classes. This pattern is particularly useful for making independently developed class libraries work together. There are following basic classification of behavioral patterns :
  • Adapter -Match interfaces of different classes .
  • Bridge -Separates an object’s abstraction 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.

ConclusionIt was fun in learning and writing an article on Design Patterns C#, Software Design Patterns, .Net Design Patterns and distinguishes between behavioral, creational, and structural design patterns. I hope this article will be helpful for enthusiastic peoples who are eager to learn and implement some interesting stuffs in new technology.

Please feel free to comment your opinion about this article or whatever you feel like telling me. Also if you like this article, don't forget to share this article with your friends. Thanks!
Software Design Patterns - .Net Reviewed by Ravi Kumar on 5:49 PM Rating: 5

No comments:

All Rights Reserved by Etechpulse © 2012 - 2017

Contact Form


Email *

Message *

Powered by Blogger.