easy, elegant and effective code…

A pattern is a type of theme of recurring events or objects. So the commonly or repeatedly occurring problems or requirements also has some pattern. These problems/requirements can be in any of the domain e.g. in engineering, medical science etc. Since the problem/requirement is recurring and many people have encountered the same, chances are that someone has already solved that problem for you and you need not to re-invent the wheel. Solution to the repeatedly occurring problems is called Design Pattern.

It would be expeditious if we don’t have to re-invent the wheel.

Software Design Pattern is a general repeatable solution to a commonly occurring problems in software engineering. A design pattern is well documented template which describes the problem, the solution, when to apply the solution and its consequences.

Following are some of the benefits of using design patterns-

  • Design patterns can speed up the development process by providing tested, proven development paradigms.
  • Design reuse.
  • Common vocabulary.
  • Providing the reference to a specific design pattern can save lots of documentation efforts.

Design patterns are mainly grouped into three categories –

  • Creational Design Pattern
  • Structural Design Pattern
  • Behavioral Design Pattern
Creational Design Pattern

A creational design pattern (as it’s name suggests) maily deals with object creation.

e.g. – Abstract Factory, Builder, Factory Method, Singleton, Prototype etc.

Creational patterns can further devided into two classes – Object Creational Pattern and Class Creational Pattern.

Object Creational Pattern

Object Creational Patterns use delegation in the instantiation process.

Class Creational Pattern

Class Creational Patterns use inheritance in instantiation process thus defers its object creation to subclass.

Structural Design Pattern

A structural design pattern uses composition to merge objects and classes into larger structures. They show you how to glue different pieces of a system together in a flexible and extensible fashion. Structural design patterns help you guarantee that when one of the parts changes, the entire structure does not need to change. They also show you how to recast pieces that do not fit (but that you need to use) into pieces that do fit.

e.g. – Adapter, Bridge, Composite, Decorator, Facade, Proxy etc.

Behavioral Design Pattern

A behavioral design pattern abstracts an action you want to take from the object or class that takes the action. By changing the object or class, you can change the algorithm used, the objects affected, or the behavior, while still retaining the same basic interface for client classes.

e.g. – Chain of responsibility, Command, Mediator, Observer, Strategy, Template method etc.

Well …enough theory on the design pattern. I am planning next couple of posts on the sample Java implementation of various design pattern. I am not going to provide you any theory for specific design pattern however I’ll be providing you the reference of the resources where you can find theoretical description of a design pattern.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: