Errata


Print Print Icon

Submit your own errata for this product.


The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.


Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question



Version Location Description Submitted By Corrected
Other Digital Version xvi

Line -15
Inserted after the words web site, the phrase http://patterns.cs.up.ac.za. There is also an official
O'Reilly website at

Anonymous  Jul 2008
Other Digital Version xxi

Inserted after the last line:
My sincere thanks to all the readers who have send in comments and suggested corrections. I
particularly wish to thank Philip Fitzimmons, Dominik Gruntz and Brian Holland for their careful
reading of the text. Jim Whitehead, Nigel Horspool and Alastair van Leeuwen continually make me
defend my corner in the nicest possible way, leading to a better book all round.
Judith Bishop
July 2008

Anonymous  Jul 2008
Printed Page xvi

Line -15
Inserted after the words web site, the phrase http://patterns.cs.up.ac.za. There is also an official
O’Reilly website at

Anonymous  Aug 2008
Printed Page xxi

Inserted after the last line:
My sincere thanks to all the readers who have send in comments and suggested corrections. I
particularly wish to thank Philip Fitzimmons, Dominik Gruntz and Brian Holland for their careful
reading of the text. Jim Whitehead, Nigel Horspool and Alastair van Leeuwen continually make me
defend my corner in the nicest possible way, leading to a better book all round.
Judith Bishop
July 2008

Anonymous  Aug 2008
Other Digital Version 11

Line 12
Replaced "inherits" with "implements"

Anonymous  Jul 2008
Printed Page 11

Line 12
Replaced inherits from by implements

Anonymous  Aug 2008
Other Digital Version 12

Line 13
Removed this line entirely (IComponent Any Photo). It is a duplicate of the first line in the table.

Anonymous  Jul 2008
Printed Page 12

Line 13
Removed this line entirely (IComponent Any Photo). It is a duplicate of the first line in the table.

Anonymous  Aug 2008
Other Digital Version 17

Line -11
Replaced Tag with TaggedPhoto keeping the courier font

Anonymous  Jul 2008
Other Digital Version 17

Line -8
Replaced Tag with TaggedPhoto keeping the courier font

Anonymous  Jul 2008
Other Digital Version 17

Line -7
Replaced Tag with TaggedPhoto keeping the courier font

Anonymous  Jul 2008
Printed Page 17

Line –11
Replaced Tag with TaggedPhoto keeping the courier font

Anonymous  Aug 2008
Printed Page 17

Line –8
Replaced Tag with TaggedPhoto keeping the courier font

Anonymous  Aug 2008
Printed Page 17

Line –7
Replaced Tag with TaggedPhoto keeping the courier font

Anonymous  Aug 2008
Other Digital Version 18

Line 1
Replaced Tags with TaggedPhoto class keeping the courier font for the first word only

Anonymous  Jul 2008
Other Digital Version 18

Line 1
Replaced Tag with TaggedPhoto keeping the courier font

Anonymous  Jul 2008
Printed Page 18

Line 1
Replaced Tags with TaggedPhoto class keeping the courier font for the first word only

Anonymous  Aug 2008
Printed Page 18

Line 1
Replaced Tag with TaggedPhoto keeping the courier font

Anonymous  Aug 2008
Other Digital Version 19

Line 8
Inserted the word static in courier font before the word List and moved everything so that static
lines up under static just above it in line 7

Anonymous  Jul 2008
Printed Page 19

Line 8
Inserted the word static in courier font before the word List and moved everything so that static
lines up under static just above it in line 7

Anonymous  Aug 2008
Other Digital Version 21

Lines -15 to -13
Replaced Exercise 1 entirely by the following:
1 Referring to Example 2-1, write a new DecoratorC and experiment with new calls to the Display
method from the Main method in the Client to produce different effects.

Anonymous  Jul 2008
Printed Page 21

Lines –15 to –13
Replaced Exercise 1 entirely by the following:
1 Referring to Example 2-1, write a new DecoratorC and experiment with new calls to the Display
method from the Main method in the Client to produce different effects.

Anonymous  Aug 2008
Other Digital Version 24

Line -6
Added closing parenthesis after proxy

Anonymous  Jul 2008
Printed Page 24

Line –6
Added closing parenthesis after proxy

Anonymous  Aug 2008
Other Digital Version 27

Line -2
Removed the word ProtectionProxy and move the line back so that subject lines up above Console on the
last line.

Anonymous  Jul 2008
Printed Page 27

Line –2
Removed the word ProtectionProxy and move the line back so that subject lines up above Console on the
last line.

Anonymous  Aug 2008
Other Digital Version 29

Line 16
Replaced RealSpaceBook by SpaceBook in the same font

Anonymous  Jul 2008
Other Digital Version 29

Line 17
Replaced RealSpaceBook by SpaceBook in the same font

Anonymous  Jul 2008
Other Digital Version 29

Line 21
Replaced IsUnique by IsUsed in the same font

Anonymous  Jul 2008
Printed Page 29

Line 16
Replaced RealSpaceBook by SpaceBook in the same font

Anonymous  Aug 2008
Printed Page 29

Line 17
Replaced RealSpaceBook by SpaceBook in the same font

Anonymous  Aug 2008
Printed Page 29

Line 21
Replaced IsUnique by IsUsed in the same font

Anonymous  Aug 2008
Other Digital Version 30

Line 7
Replaced Unique by IsUsed in the same font

Anonymous  Jul 2008
Other Digital Version 30

Line -2
Lined Today I worked 18 hours up under Hello World

Anonymous  Jul 2008
Printed Page 30

Line 7
Replaced Unique by IsUsed in the same font

Anonymous  Aug 2008
Printed Page 30

Line 17
Deleted the first the

Anonymous  Aug 2008
Printed Page 30

Line –2
Lined Today I worked 18 hours up under Hello World

Anonymous  Aug 2008
Other Digital Version 31

Line 19
Replaced SpaceBook with MySpaceBook in the same font

Anonymous  Jul 2008
Other Digital Version 31

Line 20
Replaced SpaceBook with MySpaceBook in the same font

Anonymous  Jul 2008
Printed Page 31

Line 19
Replaced SpaceBook by MySpaceBook in the same font

Anonymous  Aug 2008
Printed Page 31

Line 20
Replaced SpaceBook by MySpaceBook in the same font

Anonymous  Aug 2008
Other Digital Version 32

Line 9
Replaced IsUnique by IsUsed in the same font

Anonymous  Jul 2008
Other Digital Version 32

Line -2
Replaced Unique with IsUsed in the same font

Anonymous  Jul 2008
Printed Page 32

Line 9
Replaced IsUnique by IsUsed in the same font

Anonymous  Aug 2008
Printed Page 32

Line –2
Replaced Unique by IsUsed in the same font

Anonymous  Aug 2008
Other Digital Version 34

Line 20
Lined Today I worked 18 hours up under Hello World

Anonymous  Jul 2008
Printed Page 34

Line 20
Lined Today I worked 18 hours up under Hello World

Anonymous  Aug 2008
Other Digital Version 37

Captions
The Captions on these two figures are interchanged.

Under the larger screen shot that comes first we want:
Figure 2-6 Bridge pattern illustration (a) --environment Path variable set to Version 3.5

Under the smaller screen shot we want
Figure 2-7. Bridge pattern illustration (b) -- five versions of the .NET Framework installed

Anonymous  Jul 2008
Printed Page 37

Captions
The Captions on these two figures are interchanged.

Under the larger screen shot that comes first we want:
Figure 2-6 Bridge pattern illustration (a) – environment Path variable set to Version 3.5

Under the smaller screen shot we want
Figure 2-7. Bridge pattern illustration (b) – five versions of the .NET Framework installed

Anonymous  Aug 2008
Printed Page 51

Fig 3-2
Delete the arrowed line between Component and Composite.
Create a line from IComponent down to Composite with an open arrow on the Composite end.

Anonymous 
Other Digital Version 54-55

Lines 6 and 7
Replaced all the code on these two pages by this code:

1 using System;
2 using System.Collections.Generic;
3 using System.Text; // for StringBuilder
4
5 // Composite Pattern Theory Judith Bishop Dec 2006, Aug 2007
6 // Arranges structures hierarchies so that single components and
7 // composite groups of components can be treated in the same way.
8 // Revised July 2008
9
10 namespace CompositePattern {
11
12 // The Interface
13 public interface IComponent <T> {
14 void Add(IComponent <T> c);
15 IComponent <T> Remove(T s);
16 string Display(int depth);
17 IComponent <T> Find(T s);
18 T Name {get; set;}
19 }
20
21 // The Component
22 public class Component <T> : IComponent <T> {
23 public T Name {get; set;}
24
25 public Component (T name) {
26 Name = name;
27 }
28
29 public void Add(IComponent <T> c) {
30 Console.WriteLine("Cannot add to an item");
31 }
32
33 public IComponent <T> Remove(T s) {
34 Console.WriteLine("Cannot remove directly");
35 return this;
36 }
37
38 public string Display(int depth) {
39 return new String('-', depth) + Name+"
";
40 }
41
42 public IComponent <T> Find (T s) {
43 if (s.Equals(Name))
44 return this;
45 else
46 return null;
47 }
48 }
49
50 // The Composite
51 public class Composite <T> : IComponent <T> {
52 List <IComponent <T>> list;
53
54 public T Name {get; set;}
55
56 public Composite (T name) {
57 Name = name;
58 list = new List <IComponent <T>> ();
59 }
60
61 public void Add(IComponent <T> c) {
62 list.Add(c);
63 }
64
65 // Finds the item from a particular point in the structure
66 // and returns the composite from which it was removed
67 // If not found, return the point as given
68 public IComponent <T> Remove(T s) {
69 IComponent <T> p = this.Find(s);
70 if (this!=null) {
71 (this as Composite<T>).list.Remove(p);
72 }
73 return this;
74 }
75
76 // Recursively looks for an item
77 // Returns its reference or else null
78 public IComponent <T> Find (T s) {
79 if (Name.Equals(s)) return this;
80 IComponent <T> found=null;
81 foreach (IComponent <T> c in list) {
82 found = c.Find(s);
83 if (found!=null)
84 break;
85 }
86 return found;
87 }
88
89 // Displays items in a format indicating their level
90 // in the composite structure
91 public string Display(int depth) {
92 StringBuilder s =
93 new StringBuilder(new String('-', depth));
94 s.Append("Set "+ Name + " length :" + list.Count + "
");
95 foreach (IComponent <T> component in list)
96 s.Append(component.Display(depth + 2));
97 return s.ToString();
98 }
99 }
100 }

Anonymous  Jul 2008
Printed Page 54-55

Lines 6 and 7
Replaced all the code on these two pages by this code:

1 using System;
2 using System.Collections.Generic;
3 using System.Text; // for StringBuilder
4
5 // Composite Pattern Theory Judith Bishop Dec 2006, Aug 2007
6 // Arranges structures hierarchies so that single components and
7 // composite groups of components can be treated in the same way.
8 // Revised July 2008
9
10 namespace CompositePattern {
11
12 // The Interface
13 public interface IComponent <T> {
14 void Add(IComponent <T> c);
15 IComponent <T> Remove(T s);
16 string Display(int depth);
17 IComponent <T> Find(T s);
18 T Name {get; set;}
19 }
20
21 // The Component
22 public class Component <T> : IComponent <T> {
23 public T Name {get; set;}
24
25 public Component (T name) {
26 Name = name;
27 }
28
29 public void Add(IComponent <T> c) {
30 Console.WriteLine("Cannot add to an item");
31 }
32
33 public IComponent <T> Remove(T s) {
34 Console.WriteLine("Cannot remove directly");
35 return this;
36 }
37
38 public string Display(int depth) {
39 return new String('-', depth) + Name+"
";
40 }
41
42 public IComponent <T> Find (T s) {
43 if (s.Equals(Name))
44 return this;
45 else
46 return null;
47 }
48 }
49
50 // The Composite
51 public class Composite <T> : IComponent <T> {
52 List <IComponent <T>> list;
53
54 public T Name {get; set;}
55
56 public Composite (T name) {
57 Name = name;
58 list = new List <IComponent <T>> ();
59 }
60
61 public void Add(IComponent <T> c) {
62 list.Add(c);
63 }
64
65 // Finds the item from a particular point in the structure
66 // and returns the composite from which it was removed
67 // If not found, return the point as given
68 public IComponent <T> Remove(T s) {
69 IComponent <T> p = this.Find(s);
70 if (this!=null) {
71 (this as Composite<T>).list.Remove(p);
72 }
73 return this;
74 }
75
76 // Recursively looks for an item
77 // Returns its reference or else null
78 public IComponent <T> Find (T s) {
79 if (Name.Equals(s)) return this;
80 IComponent <T> found=null;
81 foreach (IComponent <T> c in list) {
82 found = c.Find(s);
83 if (found!=null)
84 break;
85 }
86 return found;
87 }
88
89 // Displays items in a format indicating their level
90 // in the composite structure
91 public string Display(int depth) {
92 StringBuilder s =
93 new StringBuilder(new String('-', depth));
94 s.Append("Set "+ Name + " length :" + list.Count + "
");
95 foreach (IComponent <T> component in list)
96 s.Append(component.Display(depth + 2));
97 return s.ToString();
98 }
99 }
100 }

Anonymous  Aug 2008
Other Digital Version 56

Line 2
Replaced "37-42" by "42-47"

Anonymous  Jul 2008
Other Digital Version 56

Line 5
Replaced 33-35 by 91-98

Anonymous  Jul 2008
Other Digital Version 56

Line 9
Replaced 46 by 51

Anonymous  Jul 2008
Other Digital Version 56

Line 14
Replaced 47 by 52

Anonymous  Jul 2008
Other Digital Version 56

Line 19
Replaced 65-74 by 68-74

Anonymous  Jul 2008
Other Digital Version 56

Line 21
Replaced 69 by 71

Anonymous  Jul 2008
Other Digital Version 56

Line 22
Replaced the word holder with this in the same font

Anonymous  Jul 2008
Other Digital Version 56

Line 23
Replaced
The holder variable is of type ...
with
The this object could be of type ...

Anonymous  Jul 2008
Other Digital Version 56

Line 26
Replaced 82 and 94 with 81 and 95

Anonymous  Jul 2008
Other Digital Version 56

Line -6
Example Photo Library is now an "A" heading


Anonymous  Jul 2008
Printed Page 56

Line 2
Replaced 37–42 by 42–47

Anonymous  Aug 2008
Printed Page 56

Line 5
Replaced 33-35 by 91–98

Anonymous  Aug 2008
Printed Page 56

Line 9
Replaced 46 by 51

Anonymous  Aug 2008
Printed Page 56

Line 14
Replaced 47 by 52

Anonymous  Aug 2008
Printed Page 56

Line 19
Replaced 65–74 by 68–74

Anonymous  Aug 2008
Printed Page 56

Line 21
Replaced 69 by 71

Anonymous  Aug 2008
Printed Page 56

Line 22
Replaced the word holder by this in the same font

Anonymous  Aug 2008
Printed Page 56

Line 23
Replaced
The holder variable is of type …
by
The this object could be of type …

Anonymous  Aug 2008
Printed Page 56

Line 26
Replaced 82 and 94 by 81 and 95

Anonymous  Aug 2008
Printed Page 56

Line -6
Example Photo Library is now an "A" heading


Anonymous  Aug 2008
Other Digital Version 57

Line -9
Removed space in front of Set

Anonymous  Jul 2008
Printed Page 57

Line –9
Removed space in front of Set

Anonymous  Aug 2008
Other Digital Version 58

Line 6
Removed space in front of Set

Anonymous  Jul 2008
Printed Page 58

Line 6
Removed space in front of Set

Anonymous  Aug 2008
Other Digital Version 60

Line -17
Inserted a colon after <T> i.e. <T>:

Anonymous  Jul 2008
Printed Page 60

Line –17
Inserted a colon after <T> i.e. <T>:

Anonymous  Aug 2008
Other Digital Version 64

Line 15
Changed from "first of our four features" to "first of our five features"

Anonymous  Jul 2008
Printed Page 64

Line 15
Changed from "first of our four features" to "first of our five features"

Anonymous  Aug 2008
Other Digital Version 65

Line 19
Added t he instruction (See over) after "indexers".

Anonymous  Jul 2008
Other Digital Version 65

Lines 26-29
Deleted these five lines, i.e. lines 6-9 of the code fragment

Anonymous  Jul 2008
Other Digital Version 65

Line -8
Replaced 13-14 by 9-10

Anonymous  Jul 2008
Other Digital Version 65

Line -6
Replaced 13 by 9 and 14 by 10

Anonymous  Jul 2008
Other Digital Version 65

Line -5
Replaced 10-16 with 6-12

Anonymous  Jul 2008
Other Digital Version 65

Line -4
Replaced 10 with 6

Anonymous  Jul 2008
Other Digital Version 65

Line -3
Replaced 12-14 by 8-10

Anonymous  Jul 2008
Printed Page 65

Line 19
Added after indexers. The instruction (See over.)

Anonymous  Aug 2008
Printed Page 65

Lines 26-29
Deleted these five lines, i.e. lines 6-9 of the code fragment

Anonymous  Aug 2008
Printed Page 65

Line –8
Replaced 13–14 by 9–10

Anonymous  Aug 2008
Printed Page 65

Line –6
Replaced 13 by 9 and 14 by 10

Anonymous  Aug 2008
Printed Page 65

Line –5
Replaced 10–16 by 6–12

Anonymous  Aug 2008
Printed Page 65

Line –4
Replaced 10 by 6

Anonymous  Aug 2008
Printed Page 65

Line –3
Replaced 12–14 by 8–10

Anonymous  Aug 2008
Other Digital Version 66

Line -8
Replaced collection with array

Anonymous  Jul 2008
Printed Page 66

Line –8
Replaced collection by array

Anonymous  Aug 2008
Other Digital Version 67

Lines 11-22
Replaced entirely by this code:

// Flyweight
public struct Flyweight : IFlyweight {
// Intrinsic state
Image pThumbnail;
public void Load (string filename) {
pThumbnail = new Bitmap("images/"+filename).
GetThumbnailImage(100, 100, null, new IntPtr());
}

public void Display(PaintEventArgs e, int row, int col) {
// Calculating extrinsic state
e.Graphics.DrawImage(pThumbnail,col*100+10, row*130+40,
pThumbnail.Width,pThumbnail.Height);
}
}

Anonymous  Jul 2008
Printed Page 67

Lines 11–22
Replaced entirely by this code:

// Flyweight
public struct Flyweight : IFlyweight {
// Intrinsic state
Image pThumbnail;
public void Load (string filename) {
pThumbnail = new Bitmap("images/"+filename).
GetThumbnailImage(100, 100, null, new IntPtr());
}

public void Display(PaintEventArgs e, int row, int col) {
// Calculating extrinsic state
e.Graphics.DrawImage(pThumbnail,col*100+10, row*130+40,
pThumbnail.Width,pThumbnail.Height);
}
}

Anonymous  Aug 2008
Printed Page 67

Lines –14 to –16
Deleted these three lines and the blank line below.

Anonymous  Aug 2008
Other Digital Version 77

Line -5
Replaced DifferentRequest with SpecificRequest in the same font

Anonymous  Jul 2008
Printed Page 77

Line –5
Replaced DifferentRequest by SpecificRequest in the same font

Anonymous  Aug 2008
Other Digital Version 80

Line 8
Replaced interfaces with from both classes

Anonymous  Jul 2008
Printed Page 80

Line 8
Replaced interfaces by from both classes

Anonymous  Aug 2008
Other Digital Version 87

Line 17
Inserted after the word respectively:
There is also another set of generic delegates introduced with the name Action that represent methods
that do not return a value.

Anonymous  Jul 2008
Printed Page 87

Line 17
Inserted after the word respectively:
There is also another set of generic delegates introduced with the name Action that represent methods
that do not return a value.

Anonymous  Aug 2008
Other Digital Version 95

Lines -14 -12 -8 -5 -1
Replaced all occurrences of Façade in courier font by Facade in courier font (no cidilla). Removing
the cidilla only applies to the courier Façade, not when the word is used in plain text.

Anonymous  Jul 2008
Printed Page 95

Lines -14 -12 -8 -5 -1
Replaced all occurrences of Façade in courier font by Facade in courier font (no cidilla). Removing
the cidilla only applies to the courier Façade, not when the word is used in plain text.

Anonymous  Aug 2008
Other Digital Version 97

Lines -12 -6 -2
Replaced all occurrences of Façade in courier font by Facade in courier font (no cidilla).

Anonymous  Jul 2008
Printed Page 97

Lines -12 -6 -2
Replaced all occurrences of Façade in courier font by Facade in courier font (no cidilla).

Anonymous  Aug 2008
Other Digital Version 98

Lines 6 7 9 10
Replaced all occurrences of Façade in courier font by Facade in courier font (no cidilla).

Anonymous  Jul 2008
Printed Page 98

Lines 6 7 9 10
Replaced all occurrences of Façade in courier font by Facade in courier font (no cidilla).

Anonymous  Aug 2008
Printed Page 111

Fig 5-3
Inside the box called Creator, the last word should be IProduct not Product

Anonymous 
Other Digital Version 112

Line 14
Replaced Shoekeeper with Shopkeeper

Anonymous  Jul 2008
Printed Page 112

Line 14
Replaced Shoekeeper by Shopkeeper

Anonymous  Aug 2008
Other Digital Version 116

Line 14
Removed the detail (3)

Anonymous  Jul 2008
Printed Page 116

Line 14
Removed the detail (3)

Anonymous  Aug 2008
Other Digital Version 118

Line -6
Replaced Instance by UniqueInstance in the same font

Anonymous  Jul 2008
Printed Page 118

Line -6
Replaced Instance by UniqueInstance in the same font

Anonymous  Aug 2008
Other Digital Version 121

Line -8
Replaced 25-27 by 26-28

Anonymous  Jul 2008
Printed Page 121

Line -8
Replaced 25-27 by 26-28

Anonymous  Aug 2008
Other Digital Version 134

Line 21
Replaced 49 by 59

Anonymous  Jul 2008
Printed Page 134

Line 21
Replaced 49 by 59

Anonymous  Aug 2008
Printed Page 141

Fig 7-2
The box on the left should be called Context not Client

Anonymous 
Printed Page 165

Fig 8-2
The large box in the centre called IHandler:
Change its name to IHandler (not italic).
The word Handler should be IHandler in plain (not italic) arial font
There should be a line coming out of the top of this box, along, down and back into the box on its
right side, with an open diamond at this end.

Anonymous 
Other Digital Version 209

Line 1
Replaced Mediator constructor with Mediator's sign on method with mediator in courier font.

Anonymous  Jul 2008
Printed Page 209

Line 1
Replaced Mediator constructor by Mediator’s sign on method with mediator in courier font.

Anonymous  Aug 2008
Printed Page 222

Fig 10-3
Remove the line between Client and Visitor1 boxes
Add a dotted line out the top of the Client box into the left side IVisitor box at the top. There
should be an open arrow on the Visitor side of the line.

Anonymous 
Printed Page 235

Fig 10-5
Remove the line between the Terminal and Nonterminal boxes.
Replace the name of the Term box by ITerm
Add a solid line out of the right side of ITerm coming down to the top of Nonterminal with an open
diamond on this end.

Anonymous 
Other Digital Version 245

Line -4
Replaced GetMemento by Restore

Anonymous  Jul 2008
Printed Page 245

Line -8
Replaced SetMemento by Save

Anonymous  Aug 2008
Printed Page 245

Line -4
Replaced GetMemento by Restore

Anonymous  Aug 2008


"If you already understand the C# programming language and have some introduction to Patterns under your belt, this book will be very exciting to you as it opens up the field to completely new possibilities."
--Peter Bromberg, EggHeadCafe.com