Errata

Head First Object-Oriented Analysis and Design

Errata for Head First Object-Oriented Analysis and Design

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
PDF Page x
lower-left image

The image on this page (and many others, but not all of them) is inverted in my PDF viewer (Safari), so they guy is wearing a white shirt with a black collar: it is like looking at a photo negative. There are similar "negative" images on page xiii, 2, 6, 7, 8, 9, etc.

I tried re-downloading, but the problem persists.

richardaustin  Jan 31, 2011 
Printed Page 5
4th line from the bottom to top

return guitar; is missing after continue;

it should be like:

...
if ((topWood!=null)&&(!topWood.equals("")) &&
(!topWood.equals(guitar.getTopWood())))
continue;
return guitar;
}
return null;
}
}

Anonymous   
Printed Page 5
code section

Second condition in if statement should be
&& (!type.equals(""))
instead of
&& (!searchGuitar.equals(""))

The code provided in the book is trying to test if the object of type guitar is equal to "" which is incorrect. It should be testing to see if type which is a string is equal to "".

Ernie Bishop  Jan 30, 2010 
Printed Page 5
code sample

The search method never returns anything when it finds a match. Even using enums and changing all strings to lower case won't help here. You'll need to add:

return guitar;

after the last if statement within the for loop.

Anonymous  Oct 26, 2010 
Printed Page 5
bottom of the page

The search method always returns null. What's missing is a "return guitar;" at the end within the loop.

kuku  Dec 15, 2010 
Printed Page 5
before close of search meathod

"return guitar;" statment of the searsch method omited/left out. Code corrected on page 17, but never discussed as "beeing a problem within the code" in the text.

Lyam Dolk  Jul 16, 2011 
Printed Page 6
end of second line of System.out.println in if block

guitar.getBuilder() + " " + guitar.getModel() + " "
should read
guitar.getBuilder() + " " + guitar.getModel() + " " +

Anonymous   
Printed Page 6 and 7
construction of whatErinLikes (on page 6) and inventory.addGuitar() on page 7

on page 6, we use the string "fender"
whereas on page 7, we use the string "Fender" (capital F).

Even if the Inventory.search() were correctly implemented, this difference would mean that we would not find what Erin wants
(the case of the builder string must match)

Anonymous   
Printed Page 6
Codebox

I talk about the german version of the book. In the code, the Fender guitar is a "Stratocastor" instead of a "Stratocaster".

yetibrain  Nov 22, 2009 
Printed Page 7
code sample

missing '+' at the end of line 13:

guitar.getBuilder() + " " + guitar.getModel() + " "

Should be:

guitar.getBuilder() + " " + guitar.getModel() + " " +

Anonymous  Oct 26, 2010 
PDF Page 17
Middle of second code snippet

Possible NullPointerException if searchGuitar.getModel() is null. The code:

String model = searchGuitar.getModel().toLowerCase();
if((model != null) && (!model.equals("")) &&
(!model.equals(guitar.getModel().toLowerCase())))

Must be changed to:

String model = searchGuitar.getModel();
if((model != null) && (!model.equals("")) &&
(!model.toLowerCase().equals(guitar.getModel().toLowerCase())))''

Or even better using equalsIgnoreCase():

String model = searchGuitar.getModel();
if((model != null) && (!model.equals("")) &&
(!model.equalsIgnoreCase(guitar.getModel())))

Carlos Bustamante  Sep 21, 2017 
Printed Page 41
In "torn sheet" of "public Guitar(String..."

The declaration of the class Guitar is the pre-GuitarSpec one:

public Guitar(String serialNumber, double price, Builder builder, String model, Type type, Wood backWood, Wood topWood)

It seems to me it should be:

public Guitar(String serialNumber, double price, GuitarSpec spec)

If I'm somehow mistaken, it wouldbe nice if someone could let me know. Thanks!

Anonymous  Mar 31, 2009 
Printed Page 45
matches method

There should be getter methods for accessing the properties in the 'otherSpec' object. All method calls are made as if the properties were public.

public boolean matches(GuitarSpec otherSpec)
{
if (this.builder != otherSpec.getBuilder())
return false;
if ((model != null)
&& (!model.equals(""))
&& (!model.toLowerCase().equals(
otherSpec.getModel().toLowerCase())))
return false;
if (type != otherSpec.getType())
return false;
if (backWood != otherSpec.getBackWood())
return false;
if (topWood != otherSpec.getTopWood())
return false;
return true;
}

Anonymous   
Printed Page 49
If your target audience is only college level and up it may not be an issue for you). The use of the word "ass" on pages xxxiii and 49 would make me hesitate recommending the book to anyone teaching programming in high school classes.

Anonymous   
Printed Page 51
The clues for the crossword puzzle are blurry. It doesn't look like a printing issue to me but the choice of font.

Anonymous   
PDF, ePub Page 67
code example

If a matching guitar is found, it should be returned, yet there is only a return statement if no match is found ("return nil").

Following the last "continue" statement there should be a "return guitar;" statement.

Anonymous  Oct 25, 2014 
Printed Page 80
Second comment to the right, next to point 3

"(...) since them pushing the button isn't something that's you have to handle"

should probably be:

"(...) since them pushing the button isn't something that you have to handle"

Anonymous  Nov 02, 2009 
Printed Page 81
Right side of the req.list

We've already got code to take care "of" this requirement
=> "of" is missing

TG  Mar 26, 2010 
Printed Page 82
2/3 of the way down

If I am reading the code on page 82 correctly, the whole example of automatically closing the door is based on the assumption that in normal circumstances (the "main path"), a dog can go outside, do its business, and get back inside within FIVE SECONDS. The note on page 83 says that is "plenty of time to get back inside before the door closes." That is one fast dog!

I kept expecting this to be pointed out as a bug and fixed, but as of the end of chapter 3, it's not. In fact, the code is repeated on page 139.

Anonymous   
Printed Page 88
Code Magnets, 2d paragraph

"(...) there is a twist... all the magents for periods"

should be:

"(...) there is a twist... all the magnets for periods"

Anonymous  Nov 02, 2009 
Printed Page 88-90
N/A

On page 89, we see the first line of output from DogDoorSimulator.java is:

"Fido barks to go outside..."

Yet this option is missing from the code magnets on page 88, and the magnet is missing from the first line of the solution on page 90.

There is nowhere else this output could have come from; page 83 re-affirms this output should have come from the DogDoorSimulator class.

Aaron Adams  Nov 22, 2009 
Printed Page 107
Crossword hint, 21 across


Hint for 21 across starts "Use cases are easeist ...". Should be "easiest".

Anonymous  Aug 18, 2008 
Printed Page 128
(answers: how many scenarios in the use case "Todd and Gina's...")

path 1 and path 6 are identical. The correct answer should thus be that there are six different scenarios, not seven.

We can double-check this since you have two independent choices on the use case, the first of which has two different option (Fido let out by bark recognizer, Fido let out by Todd/Gina), and the second which have three options (Fido not stuck outside, Fido stuck and let in by bark recognizer, Fido stuck and let in by Todd/Gina). two times three equals, again, six scenarios, not seven.

Anonymous   
Printed Page 183
lower left

Note says "... it's the SAME class diagram."

Actually, it's not because it does not include BarkRecognizer.

The same thing can be said for the note on page 185.

Anonymous   
Printed Page 193
All

The output does not match DogDoorSimulator.java.
Example:
"Bitsie" vs. "A small dog"

Anonymous   
Printed Page 196
bottom exercise solution

The arrow from Attribute should point at "Equivalent to a member variable in a class." and the arrow from Operation should point to "This is the UML term that usually represents a method in one of your classes."

Anonymous   
Printed Page 199
In the class diagram

In the class diagram shown, class Inventory is associated to class Guitar and holding a reference to the Guitar class. The reference is named "inventory" in the class diagram by mistake (I suppose). It should have been named "guitar"

The same error is there in the very next page..

And on page no 205, class Inventory is holding a reference named "inventory" to abstract class "Instrument". The reference must have been named "instrument"

Yes you allow for re-opening the door if Fido is stuck outside, but it's confusing to see that described as the "alternate path" (when something goes wrong) since it would pretty much always be used.

Anonymous   
Printed Page 199
on the Guitar Class

on the Guitar Class 'inventory *' -> 'guitars *'

Anonymous  Oct 24, 2008 
Printed Page 205
1st paragraph

"Whenever you find common behavior in two or more places, look to abstract that behavior into a class, and then reuse that behavior in the common classes"

The last two words should be "common class" (singular instead of plural).

Anonymous   
Printed Page 208
top of the page, first sentence

"We can start off be creating a new class..."

It should say "We can start off by creating a new class..."

Anonymous  May 24, 2010 
Printed Page 212
Last method - search()

The line

Mandolin mandolin = (Mandolin)i.next();

in

public List search(MandolinSpec searchSpec)

will fail at runtime if the Instrument returned by next() is of type Guitar. A instanceof check is required before the casting is done (in both search methods - the Mandolin search as well as Guitar search)

Anonymous   
Printed Page 212
search(MandolinSpec searchSpec) Method at the end of page

public List search(MandolinSpec searchSpec)
{
...
for(...)
{
xx Mandolin mandolin = (Mandolin)i.next();
if(...)
{
....
}
}
return ...;
}

The above line (marked xx) will through casting exception if the type returned is Guitar. The inventory contains Instrument type but that type could be Mandolin or Guitar.

You need another if statemnet before the line to check the type before casting.

Anonymous  Oct 18, 2010 
Printed Page 328
pagenumber of page 11 (shown as snapshot)

The page number shown is 11 but should be 13 according to my book.

TG  Apr 12, 2010 
Printed Page 344
First full paragraph, starts with "Below is ..."


The last sentence of the paragraph appears to be cut off. There is no period, and the sentence doesn't end normally -- "... and units being both added to and removed from"

Anonymous  Sep 04, 2008 
Printed Page 347 and 348
Code for Tile class on 348

The code for Board class on page 347 uses the following methods from Tile class: addUnit(Unit), removeUnit(Unit), removeUnits() and getUnits(). The code for Tile class on page 348 does not have removeUnits() and getUnits() methods! The note at the bottom on page 348 says 'we added only a few methods to Tile class', but without the above mentioned methods, the code on page 347 would not compile.

Kapil  May 19, 2011 
Printed Page 389
First comment to the left

The first comment to the left reads:

"#6 and #9 (...), but the basic functinality (...)"

It should be:

"#6 and #9 (...), but the basic functionality (...)"

Anonymous  Nov 13, 2009 
Printed Page 400
Top Title

I have an early print of this book but didn't see this mentioned as being changed in the most recent printing.
The title at the top "Contestant #4" I believe should read "Principle #4." If you look at page 390 you will see "Principle #3" on page 382 you will see "Principle #2" and on page 377 you will see "Principle #1."

No where else in this chapter does it mention Contestant #1-3.

Anonymous   
Printed Page 476
last method in UnitGroup

A call to getUnits() is going to die at runtime with a ClassCastException--the objects in the iterator aren't Units, they're Map.Entrys.

How about:
public List getUnits() {
List unitList = new LinkedList();
for (Iterator i = units.entrySet().iterator(); i.hasNext(); ) {
Unit unit = (Unit) ((Map.Entry) i.next()).getValue();
unitList.add(unit);
}
return unitList;
}

Or (less hideously) iterate over values() and use new-style for syntax:
public List getUnits() {
List unitList = new LinkedList();
for (Unit i: units.values()) {
unitList.add(i);
}
return unitList;
}

Or simply rely on the fact that values() gives us a Collection and we can construct a LinkedList directly from a Collection:
public List getUnits() {
return new LinkedList(units.values());
}

Anonymous   
519
in the code block, method "addStation"

Method is like this:

public void addStation(String stationName) {
if (! this. hasStation(station) ) {
Station station = new Station(stationName) ;
stations. add(station) ;
}
}

and it should be like this:

public void addStation(String stationName) {
if (! this. hasStation(stationName) ) {
Station station = new Station(stationName) ;
stations. add(station) ;
}
}

Fatih KUCUK  May 04, 2011 
Printed Page 593
left column

encapsulate what varies 115-116

>>>>>>>>>>

encapsulate what varies 248-249

Anonymous  Jun 15, 2012