SLIDE 4 4
Gang of 4 (GoF) Design Pattern Classification
Purpose categories described in “Design Patterns:…” by Gamma, Helm, Johnson and Vlissides; Addison-Wesley
Creational
Patterns that can be used to make object creation more flexible (e.g., Abstract Factory) or restrict creation activities (e.g., Singleton). H l k t i d d t f h bj t t d
Eunjee Song Deign Patterns Intro-19
Help make a system independent of how objects are created, composed, and represented (i.e., allows one to vary how
- bjects are created, composed, and represented)
Structural
Concerned with creating flexible mechanisms for composing
- bjects to form larger of structures
Behavioral
Concerned with creating flexible algorithms and with assigning responsibilities to classes
Scope Criterion
Scope determines whether a pattern applies to classes or objects
Classes
class relations inheritance structures (static-fixed at compile-time) examples: Factory Method (creation); Adapter
( t t l) I t t T l t M th d (b h i l)
Eunjee Song Deign Patterns Intro-20
(structural); Interpreter, Template Method (behavioral)
Objects
object relations. dynamic (can be changed at run-time) examples: Abstract Factory, Builder, Singleton
(creation); Adaptor, Bridge, Facade (structural); Iterator, Observer, Visitor (behavioral)
Catalog of 23 Design Patterns by GoF
Purpose Creational Structural Behavioral Sco
Class
Factory Method Adapter (class) Interpreter Template Method Abstract Factory* Prototype Builder Adapter (object)* Bridge* Composite * Chain of Responsibility Command* Iterator *
Eunjee Song Deign Patterns Intro-21
Object
Singleton Decorator* Facade Flyweight Proxy Mediator Observer* State Strategy * Visitor*
Scope: domain over which a pattern applies, Purpose: reflects what a pattern does
* : patterns to be covered with a Document Editor (Lexi) Example and/or an
Asteroids game example Facade Pattern: Interfacing to subsystems Observer Pattern: Maintain consistency across
redundant state, also called Publisher-Subscriber
Composite Pattern: Modeling of dynamic aggregates Strategy Pattern: Interface to a task implemented by
different algorithms Ad t P tt I t f t ld t (l
Eunjee Song
Adapter Pattern: Interface to old systems (legacy
systems)
Bridge Pattern: Interfacing to existing and future
systems
Proxy Pattern: Reduces the cost of accessing
Deign Patterns Intro-22
Why Study Design Patterns?
Reuse existing, high-quality solutions to
commonly recurring problems
Establish common terminology to improve
communications within teams Shift th l l f thi ki t hi h
Eunjee Song Deign Patterns Intro-23
Shift the level of thinking to a higher
perspective (i.e., help us see the forest AND the trees)
Decide whether I have the right design, not
just one that works.
Why Study Design Patterns? (cont…)
Improve individual learning and team learning Improve the modification of model/code Facilitate adoption of improved design
alternatives even when patterns are not used
Eunjee Song Deign Patterns Intro-24
alternatives, even when patterns are not used explicitly