Head First Design Patterns

Errata for Head First 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. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date 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 Note Update



Version Location Description Submitted By Date Submitted Date Corrected
Printed
Page viii
2nd paragraph, line 7

... that encourage woman to ... should be: ... that encourage women to ...

Anonymous    Aug 19, 2011
Printed
Page viii
4th paragraph

"trying to restoring" should be: "trying to restore"

Anonymous    Aug 19, 2011
Printed
Page ix
3rd paragraph

runing should read: running

Anonymous    Aug 19, 2011
Printed
Page xxxi
Fourth through ninth numbered Item

Items are numbered 1,2,3,5,..,10 instead of 1,2,3,4,5,..,10.

Anonymous    Aug 19, 2011
Printed
Page xxxv
2nd Paragraph

A space is missing between the word 'their' and the following opening parenthesis. So this: "...and the impact you've had on their(and our) lives is forever." should be: "...and the impact you've had on their (and our) lives is forever."

Anonymous    Aug 19, 2011
Printed
Page 5
Box for RubberDuck

The string ".//" should be "//"

Anonymous    Aug 19, 2011
Printed
Page 9
beneath the box containing the Design Principle

thruoghout should be: throughout

Anonymous    Aug 19, 2011
Printed
Page 12
last line

Should be a.makeSound();

Anonymous   
Printed
Page 13
Box for Quack class

quack) should be quack()

Anonymous    Aug 19, 2011
Printed
Page 13
Diagram - annotation below FlyNoWay box

"And here's the implementation of all ducks that can't fly." should be "And here's the implementation for all ducks that can't fly."

Anonymous    Aug 19, 2011
Printed
Page 14
Second sentence in the second answer iin the Q&A on page 14 should

be changed to read: "As you'll see once we've got everything hooked together, we do benefit by having Duck not be an interface, and having specific ducks, like MallardDuck, inherit common properties and methods."

Anonymous    Aug 19, 2011
Printed
Page 19
description of step 3, 3rd line

... and Sqeak.java ... should be: ... and Squeak.java ...

Anonymous    Aug 19, 2011
Printed
Page 21
Code

The code is improperly indented, starting with the fourth line.

Anonymous    Aug 19, 2011
Printed
Page 21
step 5, console, last line

I'm flying with a rocket should be (in order to be consistent with the code at the bottom of the previous page): I'm flying with a rocket!

Anonymous    Aug 19, 2011
Printed
Page 23
Master and Student dialogue

Master's second-to-last remark includes "maintaintability" it should be: maintainability

Anonymous    Aug 19, 2011
Printed
Page 32
Middle of page, "OO Principles" box, 2nd sentence

"Favor composition over inheritence" should be "Favor composition over inheritance"

Anonymous    Aug 19, 2011
Printed
Page 33
Crossword puzzle

There were several errors in the crossword puzzle. A corrected version can be found here - http://examples.oreilly.com/9780596007126/chapter1crossword.pdf

Anonymous   
Printed
Page 34
1st paragraph

"... while Weapon is an interface that all weapons implement." should be "... while WeaponBehavior is an interface that all weapon behaviors implement."

Anonymous  Nov 25, 2009  Aug 19, 2011
Printed
Page 35
Sharpen Your Pencil Solution

There are two "C" boxes. The boxes should be A, B, C, D, E, F instead of A, B, C, C, D, E.

Anonymous    Aug 19, 2011
Printed
Page 41
Second bullet

The closing parenthesis is missing.

Anonymous    Aug 19, 2011
Printed
Page 52
Q&A section at bottom

Minor layout booboo: missing "There are no Dumb Questions" heading

Anonymous    Aug 19, 2011
Printed
Page 56
UML

"CurrentConditions" should be "CurrentConditionsDisplay" (as it is in the code on p. 60). Also On page 56, the "subject" arrow from CurrentConditions (which should read CurrentConditionsDisplay) should point to the Subject interface, rather than WeatherData.

Anonymous    Aug 19, 2011
Printed
Page 64
UML

On page 64, the "subject" arrow from GeneralDisplay should point to Observable rather than WeatherData.

Anonymous    Aug 19, 2011
Printed, PDF, ePub, Mobi
Page 64
Class Diagram, concrete Observers

The GeneralDisplay observer should be CurrentConditionsDisplay

Elisabeth Robson
Elisabeth Robson
O'Reilly AuthorO'Reilly Blogger 
Aug 09, 2013 
Printed
Page 65
last paragraph

notifyObserver(arg) should read: notifyObservers(arg)

Anonymous    Aug 19, 2011
Printed
Page 78
In the Code Magnets solution, the line -

Weatherdata weatherData = (WeatherData)observable; should not appear in the ForecastDisplay constructor, as it does now, but rather as the first line in the update() method.

Anonymous   
Printed
Page 87
3rd answer, near middle of paragraph

would probably be wastefu). Following should be: would probably be wasteful). Following

Anonymous    Aug 19, 2011
Printed
Page 87
last A, first sentence

remove extra "the" before "knowing the domain" ...in designing OOP systems and also a matter of the knowing the domain... should be: ...in designing OOP systems and also a matter of knowing the domain...

Anonymous    Aug 19, 2011
Printed
Page 91
The two ConcreteDecorators

ConcereteDecoratorA and ConcereteDecoratorB should be: ConcreteDecoratorA and ConcreteDecoratorB

Anonymous    Aug 19, 2011
Printed
Page 91
bottom left bullet text

"The ConcreteDecorator has an instance variable for the thing it decorate.. should be: "The ConcreteDecorator has an instance variable for the thing it decorates."

Anonymous    Aug 19, 2011
Printed
Page 94
in the first paragraph,

the word "lotte" should be: "latte"

Anonymous    Aug 19, 2011
Printed
Page 96
Third annotation down on Espresso, second sentence

"Now that we don't need to worry about ..." should read just "We don't need to worry about ..."

Anonymous    Aug 19, 2011
Printed
Page 96
Annotation at the bottom of the page

"You can create the other three Beverage classes (DarkRoast, Decaf, Esperesso) in exactly the same way. should read: "You can create the other two Beverage classes (DarkRoast and Decaf) in exactly the same way.

Anonymous    Aug 19, 2011
Printed
Page 97
Number 2 at the right

It is write "to to" instead of "to" : Here, we're going to to pass the beverage ...

Note from the Author or Editor:
change: Here, we're going to to pass the beverage ... to: Here, we're going to pass the beverage ...

Anonymous    Aug 19, 2011
Printed
Page 98
Starred annotation under the code

We're going to see a much better way of creating decorated objects when we cover the Factory and Builder Design Patterns. add to the existing annotation: Please note that the Builder Pattern is covered in the Appendix.

Anonymous    Aug 19, 2011
Printed
Page 99
Question 1

"specfic" should be: "specific"

Anonymous    Aug 19, 2011
Printed
Page 99
second Q paragraph

At the end of the second Question paragraph, it says "which means it would not including Whip in the order." That should be "include" instead of "including."

Anonymous    Aug 19, 2011
Printed
Page 99
Last Question

The second sentence says "Say, I wanted my getDecription..." it should say: "Say, I wanted my getDescription..."

Anonymous    Aug 19, 2011
Printed
Page 99
Last Answer

The last sentence says "Note that getDecription..." it should say: "Note that getDescription..."

Anonymous    Aug 19, 2011
Printed
Page 100
2nd handwritten comment from top

There is a period missing at the end of the first line. "FileInputStream is the component that's being decorated The Java I/O..."

Note from the Author or Editor:
change: "FileInputStream is the component that's being decorated The Java I/O..." To: "FileInputStream is the component that's being decorated. The Java I/O..."

Anonymous    Aug 19, 2011
Printed
Page 106
1st box

public float cost(){ should be: public double cost(){

Anonymous    Aug 19, 2011
Printed
Page 106
in the bottom solution box at the very top

"double mocha soy lotte with whip" should be: "double mocha soy latte with whip"

Anonymous    Aug 19, 2011
Printed
Page 107
getSize method of Soy class

public getSize() { SHOULD BE: public int getSize() {

Anonymous    Aug 19, 2011
Printed
Page 109
last line

embarrasing -> embarrassing

Anonymous    Aug 19, 2011
Printed
Page 113
last line in highlighted block of code.

pizza = new eggiePizza(); should be: pizza = new VeggiePizza();

Anonymous    Aug 19, 2011
Printed
Page 114
last 3rd line in last paragraph

a client of that object. Any time it needs a pizzam it asks should be: a client of that object. Any time it needs a pizza it asks

Anonymous    Aug 19, 2011
Printed
Page 115
bottom right, answer to last question

"But remember it also has the disadvanage..." should be: "But remember it also has the disadvantage..."

Anonymous    Aug 19, 2011
Printed
Page 117
Bottom "Just another reminder:.." Second line;

"write a class the implements ... should be "write a class that implements ...

Anonymous    Aug 19, 2011
Printed
Page 119
third line in the two listings

line 3: There should be "nyStore.orderPizza" instead of "nyStore.order" line 6: There should be "chicagoStore.orderPizza" instead of "chicagoStore.order"

Anonymous    Aug 19, 2011
Printed
Page 120
last line in code example

abstract createPizza(String type); should be: abstract Pizza createPizza(String type);

Anonymous    Aug 19, 2011
Printed
Page 121
Second paragraph

Erroneous space after first "thick".

Anonymous    Aug 19, 2011
Printed
Page 130
black output window at the bottom

"Grated Regiano cheese" should be: "Grated Reggiano Cheese" [in order to match the code shown on page 129]

Anonymous    Aug 19, 2011
Printed
Page 134
Last paragraph

The last sentence should start with 'They say "decide"'

Anonymous    Aug 19, 2011
Printed
Page 135
Last Answer (A)

framework that let's >> framework that lets

Thomas Kennedy  Nov 03, 2010  Aug 19, 2011
Printed
Page 144
Last paragraph

"different set that needs to shipped..." should be "different set that needs to be shipped..."

Anonymous    Aug 19, 2011
Printed
Page 145
in the California group;

the seafood should be "Calamari", not "Camari"

Anonymous    Aug 19, 2011
Printed
Page 148
UML drawing of classes at the bottom of the page

"Mozzarella" class name should be "MozzarellaCheese" (to match p. 145)

Anonymous    Aug 19, 2011
Printed
Page 150 & 151
last method

Wrong way double-quotes

Anonymous    Aug 19, 2011
Printed
Page 159
2nd paragraph, right column (Abstract Factory)

"...because I am used to create entire families..." should read: "...because I am used to creating entire families..."

Anonymous    Aug 19, 2011
Printed
Page 160
text floating in bottom-middle of diagram

"Subclasses are instaniated by the Factory Methods." It should be "Subclasses are instantiated by the Factory Methods."

Anonymous    Aug 19, 2011
Printed
Page 162
Abstract Factory Card

depedent should be: dependent

Anonymous    Aug 19, 2011
Printed
Page 173
floating "a" inside "Watch it" box on the top right of the page

"you'll see a it has a few issues later in the chapter". It should be "you'll see it has a few issues later in the chapter"

Anonymous    Aug 19, 2011
Printed
Page 175
fill method

"fill" is rendered improperly (with a hard-to-read font)

Anonymous   
Printed
Page 179, 204
"Bet the JVM" code example

code example; ChocolateBoiler boiler = ChocolateBoiler.getInstance(); fill(); boil(); drain(); should be: ChocolateBoiler boiler = ChocolateBoiler.getInstance(); boiler.fill(); boiler.boil(); boiler.drain(); (204, Text above the black box on the bottom-right of the page: "Here, create a command and pass it to the receiver." it should be : "Here, create a command and pass the receiver to it."

Anonymous    Aug 19, 2011
Printed
Page 189
Use eager instantiation answer

statically inializing >> statically initializing

Thomas Kennedy  Nov 04, 2010  Aug 19, 2011
Printed
Page 207
in the text pointing to the Command interface,

the word should be "perform", not "preform"

Anonymous    Aug 19, 2011
Printed
Page 208
Second paragraph, Sue's statement

Sue's last sentence ends with a colon, but no example follows it. After the colon at the end of Sue's statement, add: "onCommands[0] = onCommand; offCommands[0] = offCommand; and so on for each of the seven command slots."

Anonymous    Aug 19, 2011
Printed
Page 209
swapped letters "ie" in "reciever", bottom right of the page

"(3) In the execute() method actions are invoked on the reciever." It should be: "(3) In the execute() method actions are invoked on the receiver."

Anonymous    Aug 19, 2011
Printed
Page 212
first paragraph

"Home Automation of Bust" should be "Home Automation or Bust"

Anonymous    Aug 19, 2011
Printed
Page 216
In the thought bubble

Printed:

Note from the Author or Editor:
Should replace "!!!!" with "?!"

B Hillebrecht  Jun 26, 2009  Aug 19, 2011
Printed
Page 223
RemoteLoader output window

The output in the window on page 223 does not match the code on page 222. Code has remoteControl.setCommand(0, ceilingFanMedium, ceilingFanOff); remoteControl.setCommand(1, ceilingFanHigh, ceilingFanOff); The output window has: [slot 0] headfirst.command.undo.NoCommand headfirst.command.undo.NoCommand [slot 1] headfirst.command.undo.CeilingFanMediumCommand headfirst.command.undo.CeilingFanOffCommand [slot 2] headfirst.command.undo.CeilingFanHighCommand headfirst.command.undo.CeilingFanOffCommand but should be: [slot 0] headfirst.command.undo.CeilingFanMediumCommand headfirst.command.undo.CeilingFanOffCommand [slot 1] headfirst.command.undo.CeilingFanHighCommand headfirst.command.undo.CeilingFanOffCommand [slot 2] headfirst.command.undo.NoCommand headfirst.command.undo.NoCommand

Anonymous    Aug 19, 2011
Printed
Page 230
1st bullet point

"The Command Pattern decouples an object, making a request from the one that knows how to perform it." remove comma

Anonymous    Aug 19, 2011
Printed
Page 230
5th bullet point

"excute()" should be "execute()"

Anonymous    Aug 19, 2011
Printed
Page 233
undo() definition of top exercise

The boxed text reads: "for (int i = 0; i < commands.length; i++) { commands[i].undo(); }" The commands need to be undone in *reverse* order, like so: "for (int i = commands.length - 1; i >= 0; i--) { commands[i].undo(); }"

Anonymous    Aug 19, 2011
Printed
Page 240
Test run at the bottom

Replace RemoteControlTest with DuckTestDrive and remove newlines that are not in the code: %java DuckTestDrive The Turkey says... Gobble gobble I'm flying a short distance The Duck says... Quack I'm flying The TurkeyAdapter says... Gobble gobble I'm flying a short distance I'm flying a short distance I'm flying a short distance I'm flying a short distance I'm flying a short distance

Anonymous    Aug 19, 2011
Printed
Page 245
first paragraph

")." should be ".)"

Anonymous    Aug 19, 2011
Printed
Page 273
1st paragraph

Spelling mistake: 'Enumaration'.

Note from the Author or Editor:
Enumaration -> Enumeration

Anonymous  Aug 29, 2008  Aug 19, 2011
Printed
Page 278
Top of page, annotation next to prepareRecipe(), 2nd sentence

"the second and forth steps are different, ..." should be "the second and fourth steps are different, ..."

Anonymous    Aug 19, 2011
Printed
Page 292
first "handwritten" comment

"a condiments" should be "condiments"

Anonymous    Aug 19, 2011
Printed
Page 295
bottom right of page, last paragraph

"so you can implement these as hooks rather than abstract classes," It should be: "so you can implement these as hooks rather than abstract methods,"

Anonymous    Aug 19, 2011
Printed
Page 298
third description in Who Does What? box

"Subclasses decide which concrete classes to create." It should be: "Subclasses decide which concrete classes to instantiate."

Anonymous    Aug 19, 2011
Printed
Page 300
first "handwritten" comment

"paired" should be "pared"

Anonymous    Aug 19, 2011
Printed
Page 305
Last Answer (A)

is used by the tempate -> is used by the template

Thomas Kennedy  Nov 09, 2010  Aug 19, 2011
Printed
Page 308
first "Template Method" paragraph

Missing terminating period

Anonymous    Aug 19, 2011
Printed
Page 321
bullet item #1

"...you'll need to call the getMenuItem() method ..." should be: "...you'll need to call the getMenuItems() method ..."

Anonymous    Aug 19, 2011
Printed
Page 321
second code excerpt

Improper facing closing double-quotes

Anonymous    Aug 19, 2011
Printed
Page 322, 328, 330
Sharpen your pencil box

Items are lettered A, B, C, C, D, E. Should be A, B, C, D, E, F. [328 + 330] 1st paragraph, 2nd sentence; The "getIterator()" text on pages 328 and 330 (first paragraph, both pages) should be replaced with "createIterator()"

Anonymous    Aug 19, 2011
Printed
Page 332
last line, first column

you'llwant should read: you'll want

Anonymous    Aug 19, 2011
Printed
Page 338
3rd Question

"Could I implement an Iterator that can go backwards as well as backwards?" should be: "... backwards as well as forwards?"

Anonymous    Aug 19, 2011
Printed
Page 350, 382
6th magnet

The code position = rightNow.DAY_OF_WEEK % 2; should be: position = rightNow.get(Calendar.DAY_OF_WEEK) % 2;

Anonymous    Aug 19, 2011
Printed
Page 354
1st paragrah

second to the last line of paragraph: "... chefs that the time as come for us..." should be "... chefs that the time has come for us..."

Anonymous    Aug 19, 2011
Printed
Page 365
Description for Apple Pie on the desertMenu definition

"icecream" should be "ice cream"

Anonymous    Aug 19, 2011
Printed
Page 365
Second hand-written comment from the top

Text states: "We also need two top level menu now that we'll name allMenus." Corrected Version: "We also need a top level menu that we'll name all Menus."

Anonymous    Aug 19, 2011
Printed
Page 374
Description for Apple Pie on the menu printout (in two places)

"icecream" should be "ice cream"

Anonymous    Aug 19, 2011
Printed
Page 378
11 down:

Hashtable and ArrayList both implement this interface. Should be: ArrayList implements this interface.

Anonymous   
Printed
Page 379
Who Does What?

Replace the text "State Pattern" at the top left of the diagram with "Strategy Pattern", and replace the description on the bottom right of the page, "Allows an object to change its behavior when some state changes" with "Encapsulates interchangeable behaviors and uses delegation to decide which one to use."

Anonymous    Aug 19, 2011
Printed
Page 381
Sharpen your pencil solution box

Items are lettered A, B, C, C, D, E. Should be A, B, C, D, E, F.

Anonymous    Aug 19, 2011
Printed
Page 392
first sentence

A comma is missing after "methodology".

Anonymous    Aug 19, 2011
Printed
Page 396
Sharpen your pencil box

Items are lettered A, B, C, C, D, E. Should be A, B, C, D, E, F.

Anonymous    Aug 19, 2011
Printed
Page 397
repeated "this" in second to last sentence by Joe

"I wonder if this will this make it easier to add new states?" It should be: "I wonder if this will make it easier to add new states?"

Anonymous    Aug 19, 2011
Printed
Page 398
Textballoon

First sentence: "Now we're going put all the behavior..." should be: "Now we're going to put all the behavior..."

Anonymous    Aug 19, 2011
Printed
Page 425
Sharpen your pencil box

Items are lettered A, B, C, C, D, E. Should be A, B, C, D, E, F.

Anonymous    Aug 19, 2011
Printed
Page 428
Top (Who does What)

The solutions for Template Method and Strategy are wrong; Template Method should point to the solution that Strategy is pointing to (i.e., the solution beginning, "Subclasses decide...") and Strategy should point to the solution that Template Method is pointing to (i.e., the solution beginning, "Encapsulate interchangeable behaviors..."). The solution for State is correct.

Anonymous    Aug 19, 2011
Printed
Page 431
code

Improper facing double-quotes

Anonymous    Aug 19, 2011
Printed
Page 445
Last "hand-written" note on bottom of page

The word "rmiregistery" should be "rmiregistry".

Anonymous    Aug 19, 2011
Printed
Page 446
Code Up Close, 1st "callout"

Book says: "The client always uses the remote implementation as the type of the service." Should say: "The client always uses the remote interface as the type of the service."

Anonymous    Aug 19, 2011
Printed
Page 448
Geek bits, first paragraph

>hand-deliver the these

Note from the Author or Editor:
change: hand-deliver the these to: hand-deliver these

Thomas Kennedy  Nov 10, 2010  Aug 19, 2011
Printed
Page 452
Comment pointing to NoQuarterState class

"Note that this can be slightly dangerous if you try to access this field once its been serialized and transferred." Should be: "Note that this can be slightly dangerous if you try to access this field once it's been serialized and transferred."

B Hillebrecht  Jun 24, 2009  Aug 19, 2011
Printed
Page 455
GumballMonitorTestDrive code

As written, the GumballMonitorTestDrive will fail with a NullPointerException if a GumballMachineRemote fails to initialize. If Naming.lookup() throws a RemoteException for the the second location, the second index in the GumballMonitor[] will remain null. Later, you loop over all the elements in GumballMonitor[] and call report() -- which will throw a NullPointerException on the second index. Your example should have (at the very least) done a null check on the array elements. Or (even better) used a Collection<GumballMonitor> and iterated over elements added only if the Naming.lookup() was successful.

Note from the Author or Editor:
Yes, we should check for a null pointer. But in this example, we can assume that the remote will always start correctly.

Anonymous  Jun 24, 2009 
Printed
Page 456
Code execution windows at the bottom of the page

java GumballMachine santafe.mightgumball.com 100 should be: java GumballMachineTestDrive santafe.mightgumball.com 100

Anonymous    Aug 19, 2011
Printed
Page 457
Code execution window

java GumballMonitor should be: java GumballMonitorTestDrive

Anonymous    Aug 19, 2011
Printed
Page 471
middle column, top paragraph

"If they were coupled the client would have to wait until each image is retrieved before it could paint it entire interface." should be: "If they were coupled the client would have to wait until each image is retrieved before it could paint its entire interface."

Anonymous    Aug 19, 2011
Printed
Page 507
System.out.println() line in code

The message text in the System.out.println() statement does not match the output in the window below. Code has "The ducks quacked <n> times". The output window has "<n> quacks were counted". This error also occurs in several other downstream pages, 510 and 514 at least.

Anonymous   
Printed
Page 521
Step 18

Second sentence should read "Let's update the simulator and give it a try:" not "...give it try:"

Anonymous    Aug 19, 2011
Printed
Page 526
bottom paragraph, first column

"applications" should be "application's"

Anonymous    Aug 19, 2011
Printed
Page 527
second to last stanza in left column

"repititious" should be "repetitious"

Anonymous    Aug 19, 2011
Printed
Page 527
bottom of the page

Update the link to the MVC song to: http://www.youtube.com/watch?v=YYvOGPMLVDo

Elisabeth Robson
Elisabeth Robson
O'Reilly AuthorO'Reilly Blogger 
Jun 01, 2009  Aug 19, 2011
Printed
Page 557
1st paragraph, 2nd to last sentence

minor typo: "and displayed in a seb browser." should be "and displayed in a web browser."

Anonymous    Aug 19, 2011
Printed
Page 591
bottom right answer on the page

remove the sentence: "It's a subtle distinction, especially when you consider the structural similarities between Decorator (a structural pattern) and Proxy (a behavioral pattern)."

Anonymous    Aug 19, 2011
Printed
Page 620
repetition production

Improper facing single quote to the right of the left parenthesis.

Anonymous    Aug 19, 2011
Printed
Page 620
repetition

repetition ::= ... <expresion> should be <expression>

Thomas Kennedy  Nov 18, 2010  Aug 19, 2011