Errata

C# 3.0 Design Patterns

Errata for C# 3.0 Design Patterns

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.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page xvi
2nd paragraph

If you are a programmer who loves your code,...

should be:

if you are a programmer who loves his code,...

Anonymous  Jan 11, 2009 
2.2.4
Example 2-3

Line 61 reads:
subject = new( );
which generates a design-time error.

On lines:
63 Console.WriteLine((subject as ProtectionProxy).Authenticate("Secret"));
64 Console.WriteLine((subject as ProtectionProxy).Authenticate

When the novice C# reader sees this conversion, with the ambiguous new(), it's unclear that the program will only run without a NullReferenceException if subject = new ProtectionProxy.
Could lines 61,63,64 be considered redundant?

webster.net  Mar 30, 2009 
Printed Page 4
Aggregation

In the book it is written:
"A has a B, and B can outlive A"

I think correct is:
"A has a B, and A can outlive B"

Anonymous   
Printed Page 14
Line 3

'class DecoratorPattern {' should read 'namespace DecoratorPattern {'

Gary Stafford  Apr 14, 2010 
Printed Page 18
1st paragraph

ListTags does not exist on the Example 2-2.
ListTags --> ListTaggedPhotos

Anonymous  Jan 11, 2009 
Printed Page 18
Example 2-2

Identical to the problem with 2-1, the line: 'class DecoratorPatternExample {' should read 'namespace DecoratorPatternExample {'. Obviously, these examples were not tested?

Gary Stafford  Apr 17, 2010 
Printed Page 19
Member variables of class TaggedPhoto

The variable "List <string> tags = new List <string> ();" of the class TaggedPhoto must be declared static.

Anonymous   
Printed Page 19
Member variables of class TaggedPhoto

The variable "List <string> tags = new List <string> ();" of the class TaggedPhoto must be declared static.

Anonymous  Jul 26, 2008 
Printed Page 19
variable declaration of TaggedPhoto class

List<string> is not declared static, so every instance of TaggedPhoto could only ever have one tag in the list, eg. ListTaggedPhotos will always only return one item.

Anonymous  Nov 09, 2008 
PDF Page 19
Sample code line #56, on the page 9th line.

The line:
List<string> tags = new List<string>();

Should be:
static List<string> tags = new List<string>();

To support the following output:

/* Output
TaggedPhotos: Food Yellow
TaggedPhotos: Food Yellow Jug
*/

Joel Enriquez  Sep 19, 2009 
Printed Page 21
Exercises #3

Exercise #2 reads:

For example, on OnClick event could cause a tag to appear, rather than having it appear automatically.

Should be:

For example, on Click event could cause a tag to appear, rather than having it appear automatically.

Aaron Luna  Aug 02, 2016 
PDF Page 23
Figure 2-5. Proxy pattern UML diagram

In order to fulfil the Proxy Pattern, the Subject class must implement the ISubject interface. This hasn't been done in the UML diagram.

Alan Cummings  Aug 01, 2009 
Printed Page 24
4th bullet

The 4th bullet item on this page is missing a closing parenthesis.

Anonymous  Aug 11, 2008 
Printed Page 27
Code Line 61

Line 61 of code reads:
'subject = new();'
I believe it should read:
'subject = new ProtectionProxy();'

Anonymous  Apr 18, 2010 
Printed Page 33
Check() method

If you are going to make a call to Authenticate() in the method it should be unconditional if
password != null, otherwise the logic is not consistent.

Anonymous   
PDF Page 42
class TaggedPhoto

The List<string> tags member should be declared as static to receive the output as shown in example.

/* Output
TaggedPhotos are: Food Yellow
TaggedPhotos are: Food Yellow Jug
*/

Andrii Litvinov  Apr 27, 2011 
Printed Page 55
line 70

In the following code

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 }

I believe that line 70 should read as follows to implement what the comments claim:

70 if (p!=null) {

or, if one is using the online samples (which do not match either the book or the errata samples!) the corresponding code should read

// Finds the item from a particular point in the structure
// and returns the composite from which it was removed
// If not found, return the point as given
public IComponent <T> Remove(T s) {
holder = this;
IComponent <T> p = holder.Find(s);
if (p!=null) {
(holder as Composite<T>).list.Remove(p);
return holder;
}
else
return this;
}

Andrew Layman  Dec 14, 2010 
PDF Page 60
Exercise 5

Interface definition is:
interface IComposite<T> IComponent where T : IComponent

I believe it should be:
interface IComposite<T> where T : IComponent
or
interface IComposite<T> : IComponent where T : IComponent

Polina K  May 18, 2013 
PDF Page 68
In the source code of public void DisplayGroups (Object source, PaintEventArgs e)

In the method
public void DisplayGroups (Object source, PaintEventArgs e)
{
int row;
foreach(string g in allGroups.Keys) {
int col;
.....
}

local variables int row and int col are not initialized.



Anonymous  Dec 16, 2009 
Printed Page 102
UML diagram

Class's name 'Class' should 'Client'

Anonymous   
Printed Page 207
Last method public void Output

I was not familiar with the InvokeRequired property, so I looked it up on MSDN and I noticed
somethingthere that might be important to note or add to your book. Basically you should check
IsHandleCreate when InvokeRequired is false, otherwise some possible bad things could occur.

Anonymous   
Printed Page 229
Example 10-2

The program, which is presented as a complete program, does not compile using Visual Studio 2008's C#
3.0 compiler. The specific errors I get when I attempt to compile the program are the following:

Error 1 The name 'VisitAllLabTest' does not exist in the current context C:Documents and Settings
miesenMy DocumentsVisual Studio 2008ProjectsLearningAdventuresVisitorPatternFunVisitor
Pattern FunProgram.cs 41 34 Visitor Pattern Fun

Error 2 The name 'VisitAllLabTest' does not exist in the current context C:Documents and Settings
miesenMy DocumentsVisual Studio 2008ProjectsLearningAdventuresVisitorPatternFunVisitor
Pattern FunProgram.cs 42 34 Visitor Pattern Fun

I did some research into the problem and it appears that the author of this example did not declare
and define the VisitAllLabTest() method.

Anonymous