Blog Post

Design patterns (short description)

,

Here is some short description of GoF design patterns. It is just to remind the explanations. so first you have to understand each design pattern separately.

Adapter Pattern: 

Convert the interface of a class into some other classes that client expects. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.

Decorator Pattern: (alternate of sub classing)

Attach additional responsibilities to an object at run-time. It follow closed for modification but open for extension SOLID rule.

Strategy Pattern: (Reduce IFs)

Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from client that use it.

Template method pattern:

Define the skeleton of an algorithm in an operation, differing same steps to sub classes. Template method lets sub classes redefine certain steps of an algorithm without changing the algorithm structure.

Visitor Pattern

Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates.
Ex :calculate IsAboveEighteen by introducing same new property in same class.

Observer Pattern:

Define a one to one dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.

Builder pattern:

Separate the construction of complex object from its representation so that the same construction process can create different representation. Ex: different configuration computer assembling by robots 

Chain of responsibility:

Avoid coupling of the sender of a request to its receiver by giving more than one object a chance to handle the request.
 Ex: Logic logic =new Logic();
        logic.Receiver=new Logger(new Email(null));
        logic.HandleMessage();

Abstract Factory pattern:

Provides an interface for creating families of related dependent object without specifying their concrete classes. Ex: DbProviderFactory

Factory Pattern:

Define an interface for creating an object but let classes decide which class to instantiate. Factory method lets a class defer instantiation to sub classes. 

Original post (opens in new tab)

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating