Design Patterns : Introduction
So its the holiday time and thought of starting with the Design patterns.
In this post I'll talk about What are design patterns?, What good to us using them?, Why and when use them? and many more. So why wait? Lets start the journey to Design patterns.
What are Design patterns?
So over the years when programmers tried to build systems that can solve problems often they encountered problems that were difficult to overcome. So after finding a solution what they did was presenting it as an future guideline where other programmers when encountered the same problem can easily surpass that. These are what we called as Design Patterns. To see how it all started we have to go back in the past.
History of Design Patterns?
All these patterns buzz started in about 1977/79 when Christopher Alexander showed interest in using using pattern in architecture. That's right not in computer, in architectural perspective. What really driven the patterns in to the programming was in 1987 when Kent Beck and Ward Cunningham started experimenting that concept in programming. i.e Re-usability of code and design. We will get on to that later.
But that is not when the world or programming came to know about the Deign patterns. That was 1994 with the book named "Design Patterns - Elements of Reusable Object-Oriented Software" which was written by four authors Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides. They called them selves as The Gang of Four (GOF).The GOF presented the following principles in their book:
- Program to an interface not an implementation
- Favor object composition over inheritance
Why we use Design Patterns?
The main intentions of introducing the Design Patterns was to give a common platform for each and every developer that is across the world and the other one is to give a best practice or a standardization of developing.
" Each pattern describe a problem which occurs over and
over again in our environment, and then describe thecore of the solution to that problem, in such a way thatyou can use this solution a million times over, withoutever doing it the same way twice "
Basically by using Design Patterns you can turn yourselves from novice to a pro.
How Many Design Patters are there?
So there are about 23 Design Patterns which can be classified further. For that we need to know about the scope of the Design Patterns.
The Scope is two dimensional, Where the two ends are Scope and the Purpose.
The Scope defines to whom the Design patterns Applies for. Is it for the Classes? or the Objects?
The Purpose define what the Design pattern does.
So to be more clarify lets get these two scopes to a table.
So you can clearly See here that Scope divided into Class and Object, Purpose divided into three namely Creational, Structural and Behavioral. Lets talk a bit more about these 3.
- Creational Design patterns
These provide flexibility in object creation. Rather than using new in creating objects this checks whether an object creation is really a necessary.
- Structural Design Patterns
Concerns with the objects and class creations. These concerns on the concepts of inheritance and creation of interfaces.
- Behavioral Design Pattern
These concerns basically on the communication between two objects or two classes to distribute responsibilities.
So That's it with this article....
Referances: