Design Patterns – Everything in the World have some kind of pattern

Pattern is something which would seem to show commonality of specific qualities or features when every time we notice or observe the subjects.

For example, we can say, almost every human have pattern of walking, eating, talking and so forth. I was watching this movie, Pi, other day, a mathematical scientist gets a notion of the world and says there is a mathematical pattern in everything that exist on this earth, and he tries to prove it.

So the design pattern for that matter is no different. As a developer, we try to solve the problems every day, and few of the times we tend to solve similar problems frequently.

Imagine a world – when we encounter problem as to one we solved before time, and if we could somehow correlate to the problem which occurred a day or long before. And, imagine a world where if we could correlate our first kind of problem which we could correlate to the problems occurred to other people and were solved those problems. What are we benefiting here? The answer is very simple; we could reuse the solution to the similar problem, and we don’t have to reinvent the wheel every time. It all seems like fantasy world, isn’t it, well not that fantasy it is as we have found the patterns of problems here and solutions to them, so the design patterns come to rescue here.

Design patterns are set of recurring software/software component design problems; the solutions are tested and proved which are maintained by software community.

There are three types of design patterns; it is also called Gang Of Four Patterns (GOF)

Creational:

  1. Abstract Factory
  2. Builder
  3. Factory Method
  4. Prototype
  5. Singleton

Structural:

  1. Adapter
  2. Bridge
  3. Composite
  4. Decorator
  5. Façade
  6. Flyweight
  7. Proxy

Behavioral:

  1. Chain of Responsibilities
  2. Command
  3. Interpreter
  4. Iterator
  5. Mediator
  6. Memento
  7. Observer
  8. State
  9. Strategy

10.  Template Methods

11.  Visitor

Explanation:

Creational Patterns:

  1. Singleton Pattern:

Problem: Maintain a single instance or state of an object.

UML Class Diagram:

Solution/Code:

Application:

 

Complexity and Frequency of use:

This is simple, widely used and well known pattern among all of the above.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s