A
brief history of design patterns:
Christopher Alexander:
Design patterns were first described by architect
Christopher Alexander in his book A Pattern Language: Towns, Buildings,
Construction (Oxford University Press, 1977).
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"
Gang of Four (or GoF):
The concept Christopher introduced and called patterns -- abstracting solutions to
recurring design problems – caught the attention of researchers in other
fields, especially those developing object-oriented software in the mid-to-late
1980s.
Research into software design patterns led to what is
probably the most influential book on object-oriented design:
Design Patterns: Elements of
Reusable Object-Oriented Software
by
Erich Gamma,
Richard Helm,
Ralph Johnson and
John Vlissides
(Addison-Wesley,
1995).
These authors are often referred to as the "Gang of
Four" and the book is referred to as the Gang of Four (or GoF) book.
You can download this book from Link: Design Patterns: Elements of Reusable Object-Oriented Software
What is a Design pattern?
“Gang of Four” described pattern as,
“A Design Pattern is a general reusable
solution to a commonly occurring problem within a given context in software
design.”
In general, a pattern has four essential elements:
- Pattern name: the pattern name is a handle we can use to describe a design problem, its solutions, and consequences in a word or two.
- Problem: It describes when to apply the pattern. It explains the problem and its context.
- Solution: the 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, because a pattern is like a template that can be applied in many different situations. Instead, the pattern provides an abstract description of a design problem and how a general arrangement of elements (classes and objects in our case) solves it.
- Consequences: The consequences are the results and trade-offs of applying the pattern.
Catalog:
In their book, “Gang of four” provided a catalog describing
23 design patterns. Other, more recent catalogs extend this repertoire and most
importantly, extend coverage to more specialized types of problems.
Design patterns are classified in to three groups by criterion
called purpose, which reflects what a pattern does. These Groups are:
1.Creational Patterns:
Creational patterns prescribe the way that objects are created.
These patterns are used when a decision must be made at the time a class is
instantiated.
Creational patterns abstract the instantiation process. They help to
make a system independent of how its objects are created, composed, and represented.
Creational patterns create objects for you, rather than having you
instantiate objects directly. This gives your program more flexibility in
deciding which objects need to be created for a given case.
List of Creational Patterns:
1. Singleton
2. Abstract Factory
3. Builder
4. Factory Method
5. Prototype
2. Structural Patterns:
Structural patterns prescribe the organization of classes and
objects. These patterns are concerned with how classes inherit from each other
or how they are composed from other classes.
List of Structural Patterns:
1. Adapter
2. Proxy
3. Composite
4. Bridge
5. Decorator
6. Façade
7. Flyweight
3. Behavioral Patterns:
Behavioral patterns prescribe the way objects interact with each
other. They help make complex behavior manageable by specifying the
responsibilities of objects and the ways they communicate with each other.
Behavioral patterns describe not just patterns of objects or
classes but also the patterns of communication between them.
List of Behavioral Patterns:
1.
Iterator
2.
Observer
3.
Mediator
4.
Chain of responsibility
5.
Command
6.
Interpreter
7.
Memento
8.
State
9.
Strategy
10. Template
Method
11. Visitor
No comments:
Post a Comment