Tuesday, 10 January 2017

What is a Design Pattern?

Christopher Alexander  says, "Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice"

A pattern has four essential elements:
  •  Pattern Name : is used to describe a design problem, its solutions, and consequences in a word or two. Naming a pattern increases our design vocabulary. It makes it easier to think about designs and convey them to others.
  • Problem : describes when to apply the pattern. It explains the problem and its context. It might describe specific design problems.
  • Solution : describes the elements that make up the design, their relationships, responsibilities, and collaborations. The solution doesn't describe a particular concrete design or implementation, since a pattern is like a template which can be applied in many different situations.
  •  Consequences : are the results and trade-offs of applying the pattern.



A design pattern names, abstracts, and identifies the key aspects of a common design structure that make it useful for creating a reusable object-oriented design.
The design pattern identifies the participating classes and instances, their roles and collaborations, and the distribution of responsibilities.
Each design pattern focuses on a particular object-oriented design problem or issue.

Organizing Design Patterns
Design patterns vary in their granularity and level of abstraction. Because there are many design patterns, we need a way to organize them.
The classification helps us learn the patterns faster.


We classify design patterns by two criteria.

1.    Purpose : reflects what a pattern does. 

Patterns can have either creational, structural, or behavioral purpose. Creational patterns concern the process of object creation. 

Structural patterns deal with the composition of classes or objects. 

Behavioral patterns characterize the ways in which classes or objects interact and distribute responsibility.


2.     Scope :  specifies whether the pattern applies primarily to classes or to objects. 

Class patterns deal with relationships between classes and their subclasses. These relationships are established through Inheritance, so they are static—fixed at compile-time. 

Object patterns deal with object relationships, which can be changed at run-time and are more dynamic.




Design Pattern
Design Pattern






No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...