User login

Essence and Design Patterns

The following table relates design patterns to relative essence. Column 'GoF' refers to the page in the Gang of Four's "Design Patterns" book describing this pattern. Column 'Kind' represents the kind of pattern based on the GoF book. Column 'Essence' describes the correlation of the pattern with relative essence: "+" (presence of pattern increases relative essence), "0" (no direct relationship between pattern and relative essence), and "-" (presence of pattern decreases relative essence).

GoF

Kind

Design Pattern

Essence

Comment

page 87

Creational

Abstract Factory

-

introduces a factory method (in addition to the necessary constructor)

page 97

Creational

Builder

-

decouples construction by going via builder's methods

page 107

Creational

Factory Method

-

introduces a factory method (in addition to the necessary constructor)

this is more about using polymorphism to treat atomic and composite objects the same, not necessarily about introducing or eliminating indirection

page 175

Structural

Decorator

-

replaces inheritance with delegation

page 185

Structural

Facade

-

introduces indirection via facade's methods

page 195

Structural

Flyweight

0

this is more about reducing the number of instances and about introducing extra parameters to pass in extrinsic state than about introducing or eliminating indirection

page 207

Structural

Proxy

-

introduces indirection via proxy's methods

page 223

Behavioral

Chain of Responsibility

(-)

0

may introduce an extra level of indirection, e.g. by calling a method invoking the next handler in a chain; however, this pattern seems to be more about replacing iteration with recursion than introducing or eliminating indirection

page 233

Behavioral

Command

-

create a class to represent a method, may directly introduce indirection (command's execute method calls original method), also adds constructor and possibly accessors

page 243

Behavioral

Interpreter

-

create a separate class for each language rule, may directly introduce indirection (separating monolithic interpret method into many interpret methods), also adds a constructors and possibly accessors

page 257

Behavioral

Iterator

-

decouples algorithm from collection, adding next and hasNext methods

page 273

Behavioral

Mediator

-

introduces indirection via mediator

page 283

Behavioral

Memento

(-)

(0)

this is more about an extra feature (being able to externalize state), not necessarily about introducing or eliminating indirection

page 293

Behavioral

Observer

-

introduces indirection through extra notify methods

page 305

Behavioral

State

-

introduces delegation to state

page 315

Behavioral

Strategy

-

introduces delegation to strategy

page 325

Behavioral

Template Method

-

breaks algorithm into smaller steps that can be factored out into template methods

page 331

Behavioral

Visitor

-

double dispatch requires two methods (visit and accept)

Analysis

Of the 23 GoF design patterns, none of them should imply a higher relative essence. Only 4 patterns are mostly uncorrelated with relative essence. The vast majority (19) represent a design with a low relative essence.