Introduction to Design Patterns:
Building Reusable Object-Oriented Software

 

Overview

 

 

What is a Design Pattern

There are four essential elements:

  1. Pattern name: to capture a design problem, its solutions and consequences in a word or two
  2. Problem: to describe when to apply the pattern
  3. Solution: to describe the elements that make up the design, their relationships, responsibilities, and collaborations.
  4. Consequences: describe the results and trade-offs of applying the pattern.

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 (Java).

 

Syntax

We will be using a consistent format to describe a particular Design Patterns

 

 

The Catalog of Design Patterns

Design Pattern Space

      Purpose  
    Creational Structural Behavioral
Scope Class Factory Method
Adapter Interpreter

Template Method

  Object Abstract Factory

Builder

Prototype

Singleton

Adapter

Bridge

Composite

Decorator

Facade

Flyweight

Proxy

Chain of Responsibility

Command

Iterator

Mediator

Memento

Observer

State

Strategy

Visitor

 

 

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 pattern.