Design Patterns Explained, First Edition Errata

Design Patterns Explained: A New Perspective on Object-Oriented Design
First Edition Errata

PART I: An Introduction to Object-Oriented Software Development


Chapter 1: The Object-Oriented Paradigm
Overview
Before The Object-Oriented Paradigm: Functional Decomposition
The Problem of Requirements
Dealing With Changes: With Functional Decomposition
Dealing with Changing Requirements
The Object-Oriented Paradigm
Special Object Methods
Summary

Typos, grammatical and other errors that have no meaning.


Special Object Methods

Typos, grammatical and other errors that have no meaning.

PART II: The Limitations of Traditional Object-Oriented Design


Chapter 4: A Standard Object-Oriented Solution
Overview
Solving with Special Cases
Summary
Supplement: C++ Code Examples

Solving with Special Cases

PART III: Design Patterns


Chapter 9: The Bridge Pattern
Overview
Introducing the Bridge Pattern
Learning the Bridge Pattern: An Example
An Observation About Using Design Patterns
Learning the Bridge Pattern: Deriving It
The Bridge Pattern in Retrospect
Field Notes: Using the Bridge pattern
Summary
Supplement: C++ Code Examples

Learning the Bridge Pattern: An Example

Page 129, Example 9-2. Correction for definition of Circle Thanks to Chetan Daku for pointing this out.

abstract class Circle {

should be

abstract class Circle extends Shape {

Supplement: C++ Code Examples

Page 159, Example 9-6. Correction for definition of Circle Thanks to Yadav Bhattarai for pointing this out.

dp1 = new V1Drawing;

s1 = new Rectangle(dp, 1, 1, 2, 3)

dp2 = new V2Drawing;

s2 = new Circle(dp, 2, 2, 4)

should be

dp1 = new V1Drawing;

s1 = new Rectangle(dp1, 1, 1, 2, 3)

dp2 = new V2Drawing;

s2 = new Circle(dp2, 2, 2, 4)

Class definition for Rectangle is also missing.


Chapter 10: The Abstract Factory Pattern
Overview
Introducing the Abstract Factory Pattern
Learning the Abstract Factory Pattern: An Example
Learning the Abstract Factory Pattern: Implementing It
Field Notes: The Abstract Factory Pattern
Relating the Abstract Factory Pattern to the CAD/CAM Program
Summary
Supplement: C++ Code Examples

Learning the Abstract Factory Pattern: Implementing It


Page 172, Example 10-3. (thanks to Ersin Eser for spotting this).
"public" misplaced. Return class should be capitalized. I've also added the abtract class ResFactory to the example for clarity.

abstract class ResFactory {

abstract public DisplayDriver getDispDrvr();
abstract public PrintDriver getPrtDrvr();
}

class LowResFact extends ResFactory {

public DisplayDriver getDispDrvr() {
return new LRDD();
}

public PrintDriver getPrtDrvr() {
return new LRPD();
}
}

class HighResFact extends ResFactory {

public DisplayDriver getDispDrvr () {
return new HRDD();
}

public PrintDriver getPrtDrvr() {
return new HRPD();
}
}

C++ Code Fragments: Implementation of ResFactory


Page 181, Example 10-6. Return class names should be capitalized. More detail of headers given.

class ResFactory {
public:
virtual DisplayDriver *getDispDrvr()=0;
virtual PrintDriver *getPrtDrvr()=0;
}

class LowResFact : public ResFactory {
public:
DisplayDriver *getDispDrvr();
PrintDriver *getPrtDrvr();
}

DisplayDriver *LowResFact::getDispDrvr() {
return new LRDD;
}

PrintDriver *LowResFact::getPrtDrvr() {
return new LRPD;
}

class HighResFact : public ResFactory {
public:
DisplayDriver *getDispDrvr();
PrintDriver *getPrtDrvr();
}

DisplayDriver *HighResFact::getDispDrvr() {
return new HRDD;
}

PrintDriver *HighResFact::getPrtDrvr() {
return new HRPD;
}

PART V: Handling Variations with Design Patterns


Chapter 16: The Singleton Pattern and the Double-Checked Locking Pattern
Overview
Introducing the Singleton Pattern
Applying the Singleton Pattern to the Case Study
The Singleton Pattern: Key Features
A Variant: The Double-Checked Locking Pattern
Field Notes: Using the Singleton and Double-Checked Locking Patterns
Summary
Supplement: C++ Code Examples

Supplemental Information

Problems with double-checked locking. Claims and counter-claims are flying across web-space about the double-checked locking pattern. Some claim it's a problem that arises from trying to fool the compiler, others claim the JVM is broken (doesn't follow its own guidelines). I haven't done enough investigation yet to see which is correct. However, one thing is certain - the double checked locking pattern doesn't work correctly under Java.

The Singleton Pattern: Key Features (thanks to Ersin Eser for spotting this).


Page 258: Participants and Collaborators should read:

Clients create an instance of the Singleton solely through the getInstance method.

Supplement: C++ Code Examples


Page 262, Example 16-3.
Remove:
USTax::USTax () {
instance= 0;
}
Add:
USTax* USTax::instance= 0;

Page 262, Example 16-4.
Remove:
USTax::USTax () {
instance= 0;
}
Add:
USTax* USTax::instance= 0;

 

Get information on the course on which the book is based:
Design Patterns Explained: A New Perspective on Object-Oriented Design

Upcoming Events