Adnan Mohsin May 05, 2017 Comments 2.00

"Design Patterns in Programming

 What is a Design Pattern?

According to MSDN, "A design pattern is a description of a set of interacting classes that provide a framework for a solution to a generalized problem in a specific context or environment. In other words, a pattern suggests a solution to a particular problem or issue in object-oriented software development.”

What are actually the main benefits of Design Patterns?

The main benefits of design patterns in software development are:

  • Flexibility
  • Adaptability to change
  • Reusability

When should we use Design Patterns?

Design Patterns are frequently useful in one of the following cases.

  • When the software application can change in definite span of time.
  • When thesoftware application contains source code that involves event notification and object creation.

 When should we not use Design Patterns?

Design patterns are not recommended in any of the following scinareos.

  • When the software application being developed would not change with time.
  • When the requirements of the source code of the application are unique.

If any condition of the above applies in the current design, there is no need to apply design patterns in the current design and avoid unnecessary complexity in the design.

What are “The Gang of Four” (GOF) Patterns?

The design patterns that we commonly use today can be attributed to the marvelous work following four persons:

  • Erich Gamma
  • Richard Helm
  • Ralph Johnson
  • John Vlissides.

These persons invented 23 design patterns in all that are commonly known as the Gang of Four patterns or the GOF patterns.

 What are the Creational Patterns?

 The Creational Patterns mainly deal with the best possible solution of creating an object or an instance of a class.  They simply provide an object creation which is a flexible approach towards object creations. The following patterns are the sub-patterns of this group.

  • Abstract Factory
  • Factory
  • Builder
  • Prototype
  • Singleton

Abstract Factory and the Factory pattern have the same purpose. The Singleton Pattern shows that there can be only single instance of a class throughout the Application’s life cycle.  A singleton class is one that can be instantiated only once in the application domain and provides a global point of access to it. 

What are the Structural Patterns?

 The Structural Patterns provides the flexibility to specify how all the objects and classes can be interoperated. The following are the sub patterns of Structural Patterns group.

  • Adapter
  • Façade
  • Bridge
  • Composite
  • Decorator
  • Flyweight
  • Proxy
  • Adapter
  • Bridge
  • Composite
  • Decorator
  • Flyweight
  • Proxy

 What are Behavioral Patterns?

 Behavioral patterns can help you define a structure for inter-object communication between objects in a system.  This design pattern is particularly used to monitor the transmission of messages when the objects communicate in a system.  The following are the sub patterns of Behavioral Patterns.

  •  Chain of Responsibility
  • Command
  • Interpreter
  • Iterator
  • Mediator
  • Memento
  • Observer
  • State
  • Strategy
  • Template Method Visitor

What is Model View Controller(MVC) Pattern in ASP.NET?

MVC consists of three kinds of objects 

  1. The Model is an application object. 
  2. The View is the presentation. 
  3. The controller defines the way the user interface responds to user inputs It is a framework that allows developers to apply the MVC pattern in the development of an ASP.NET application, thus allowing a better separation of concerns, which results in better reusability and easier testing. 

MVC Lifecycle:

  1. The request comes from the client and hits the Controller.
  2. The Controller calls the Model in order to perform some "business" operations.
  3. The Model returns the results of the operations back to the Controller.
  4. The Controller decides which View needs to be rendered and sends it the data that must be rendered.
  5. Finally the View renders the output and sends the response back to the client.  

 

Design
8/10
Support
2/10
Development
4.5/10

7.5

Awesome
3.50
Summary

What design patterns are? Why wonder now..In this article, I have explained why design patterns are important, and provided some examples

Search widget

Banner

Latest posts

Design Patterns Design Patterns in Programming

What is a Design Pattern? According to MSDN, "A design pattern is a description of a set of interacting classes that provide a framework for a solution to a generalized problem in a specific context or environment. In other words, a pattern suggests a solution to a particular problem or issue in object-oriented software development.”

May 05, 2017 16 0

C# Ref and Out parameters in C Sharp

This tutorial explains the concepts of Ref and Out Keywords in C # programming. These two keywords are also frequently asked in most interviews.

January 15, 2017 16 0

WPF Vector Graphics in WPF

In this article, I will discuss how we can create a Line, Rectangle, ellipse and Polygon control in WPF at design-time using XAML and at run-time using C#.I will also explain their properties to format such as fill property. After that, i will show you to set an image as the background of any shape object.

January 08, 2017 16 0

C# What is the difference between an Abstract Class and an Interface

One question is always out there in most interviews. What is the difference between an Abstract Class and an Interface and why do you use one over the other? It seems like a simple question but most often, the answer to this question is not sufficient for the interviewer and can cost a job. So, I have decided to write an article about them and have tried to explain it.

December 26, 2016 16 0