Introduction to Design Patterns:
Building Reusable Object-Oriented Software
- Design OO software is not easy, but design reusable object-oriented software is even
- You are almost bound to mistake when you first try out your OO design
- However, experienced object-oriented designers do make good designs
- Design patterns are the well documented experience of OO designer.
- These patterns solve specific design problems and make object-oriented designs more
flexible, elegant, and ultimately reusable.
- Once you know the pattern, a lot of design decisions follow automatically.
- Expressing proven techniques as design patterns makes them more accessible to developers
of new systems.
What is a Design Pattern
There are four essential elements:
- Pattern name: to capture a design problem, its solutions and
consequences in a word or two
- Problem: to describe when to apply the pattern
- Solution: to describe the elements that make up the design, their
relationships, responsibilities, and collaborations.
- Consequences: describe the results and trade-offs of applying the
Although design patterns supposingly describe object-oriented designs, they are based
on practical solutions that have been implemented using OOP such as C++, Smalltalk and
We will be using a consistent format to describe a particular Design Patterns
- Pattern Name and Classification
A short statement that states what does the design pattern do, rationale and intent, etc.
- Aka (Also Known As):
The alias or alternative name
A real scenario that exercise the class and object structure to solve a problem
The specific domain that the pattern will apply
Graphical representation using CRC cards, OMT or Booch to describe classes and
interactions within the pattern
Listings of classes and / or objects participating in the design pattern and their
How the participants collaborate to carry out their responsibilities.
The results and the trade-offs of using the patterns.
A checklist of how to build a solution using the design pattern. Listings of pitfalls,
hints or techniques.
- Related Patterns:
Design patterns usually work together to solve a problem. List all the related patterns in
The Catalog of Design Patterns
- Abstract Factory
- Chain of Responsibility
- Factory Method
- Template Method
Design Pattern Space
|Chain of Responsibility
How to Select a Design Pattern
Consider how design patterns solve design problems
Scan Intent sections
Study how patterns interrelate
Study patterns of like purpose
Examine a cause of redesign
Consider what should be variable in your design
How to Use a Design Pattern
Read the pattern once through for an overview.
Go back and study the Structure, Participants, and Collaborations sections.
Look at the Sample Code section to see a concrete example of the pattern in code.
Choose names for pattern participants that are meaningful in the application context.
Define the classes.
Define application-specific names for operations in the pattern.
Implement the operations to carry out the responsibilities and collaborations in the