Errata

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.

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
Chapter 1
Testing The Duck Code section

I really like the Fly and Quack behavior solutions that you've provided.

However, I have not been a fan of changing the Duck API methods to performFly() and performQuack(). I think the Duck makes much more sense if they retained their original names of fly() and quack(). This is especially the case, since swim() remains swim().

It's a design/implementation detail to delegate fly and quack behavior. Don't expose that in the API.

I've played with this example. I have added a drone Duck. They can't swim, because the water would fry the electronics. So swim becomes a behavior as well. However, my Duck still declares only fly(), quack() and swim() regardless of the underlying implementation.

James E Humelsine  Jul 19, 2020 
Chapter 2
WeatherData implementation in the Observer section

The observers are defined as:

observers = new ArrayList<Observer>();

Use the diamond operator so that it is:

observers = new ArrayList<>();

James E Humelsine  Jul 19, 2020 
ePub Page throughout title
text

Here are a list of typos encountered:

1.
Current Copy
Fewer unintended consequences from code changes and more f lexibility in your systems!

Suggested
"more f lexibility in your systems!" should be "more flexibility in your systems!"

2.
Current Copy
Paatterns can help us build ________ applications.

Suggested
"Paatterns can help us build" should be "Patterns can help us build"

3.
Current Copy
Let’s think through what we’re trying to acheive: We know the WeatherData class has getter methods for three measurement values: temperature, humidity, and barometric pressure.

Suggested
"through what we’re trying to acheive:" should be "through what we’re trying to achieve:"

4.
Current Copy
signature of the update() method so that it has no parameters: public interface Observer { public void update(); } And finally, we modify each concrete Observer to change the signature of its respective update() methds and get the weather data from the Subject using the WeatherData’s getter methods.

Suggested
"respective update() methds and get the" should be "respective update() methods and get the"

5.
Current Copy
Imagine a CondimentPrettyPrint decorator that parses the final decription and can print “Mocha, Whip, Mocha” as “Whip, Double Mocha.” Note that getDescription() could return an ArrayList of descriptions to make this easier.

Suggested
"decorator that parses the final decription and can print" should be "decorator that parses the final description and can print"

6.
Current Copy
This would make our design safe, in the sense that any inappropriate calls on elements would be caught at compile time or runtime, but we’d lose transparency and our code would have to use conditionals and the instanceof operator.

Suggested
"instanceof" should be "instance of"

Anonymous  Mar 17, 2022 
PDF Page Page 60
Code Example

In the implementation of CurrentConditionsDisplay class of Weather-O-Rama, the constructor of the said class contains two lines of code:

public CurrentConditionsDisplay(WeatherData weatherData) {
this.weatherData = weatherData
weatherData.registerObserver(this)
}

The first line assigns the weatherData from the constructor parameter to the instance variable this.weatherData. On the other hand, the second line once again uses the parameter weatherData to register the object instance of CurrentConditionsDisplay.

In other words, aside from the CurrentConditionsDisplay having its own reference of the subject instance, the instance variable weatherData of CurrentConditionsDisplay has no other purpose or usage.

WHY IT WAS THERE?

Anonymous  Jul 28, 2022 
PDF, ePub, Mobi, O'Reilly learning platform Page several
several typos

Typos:

1. Current Copy:
Fewer unintended consequences from code changes and more f lexibility in your systems!
Suggested:
"more flexibility in your systems!"

2. Current Copy:
Paatterns can help us build ________ applications.
Suggested:
should be "Patterns can help us build"

3. Current Copy:
Let’s think through what we’re trying to acheive: We know the WeatherData class has getter methods for three measurement values: temperature, humidity, and barometric pressure.
Suggested:
should be "through what we’re trying to achieve:"

4. Current Copy:
signature of the update() method so that it has no parameters: public interface Observer { public void update(); } And finally, we modify each concrete Observer to change the signature of its respective update() methds and get the weather data from the Subject using the WeatherData’s getter methods.
Suggested:
"respective update() methds and get the" should be "respective update() methods and get the"

5. Current Copy:
Imagine a CondimentPrettyPrint decorator that parses the final decription and can print “Mocha, Whip, Mocha” as “Whip, Double Mocha.” Note that getDescription() could return an ArrayList of descriptions to make this easier.
Suggested:
"decorator that parses the final decription and can print" should be "decorator that parses the final description and can print"

6. Current Copy:
This would make our design safe, in the sense that any inappropriate calls on elements would be caught at compile time or runtime, but we’d lose transparency and our code would have to use conditionals and the instanceof operator.
Suggested:
"instanceof" should be "instance of"

Anonymous  Dec 04, 2023 
PDF Page 2
Publishers + Subscribers = Observer Pattern

Hi team,

In Chapter 2. Keeping your Objects in the Know: The Observer Pattern, telling "Publishers + Subscribers = Observer Pattern". But in https://medium.com/better-programming/observer-vs-pub-sub-pattern-50d3b27f838c they're different.

XiZhi Pan  Jan 04, 2021 
Printed Page 101
1st paragraph, 2nd sentence

The sentence “InputStream acts as the abstract decorator class” appears to be inconsistent with the diagram below. FilterInputStream acts as the abstract decorator class. InputStream is annotated with “abstract component”

Anonymous  Feb 11, 2023 
PDF Page 102
Second read method in custom LowerCaseInputStream decorator

There is no need for second read method as it is surplus to the requirements that the author is trying to develop (casting all upper case to lowercase letters). First read function is enough as it is the only one being used by the client (example in main method).

Ivan Đapić  Apr 05, 2021 
Printed Page 312
Crosswords - across clues

The clue for 16 across is missing

Anonymous  Mar 16, 2021 
Printed Page 344
Last example for each loop

On the foreach loop varible name is item, but inside loop variable name changes to menuItem.

Adrian Gonzalez  Oct 19, 2022 
PDF Page 344
Code block just above the image

This error is caused by a typo in the code, where the variable menuItem is used instead of item in the for loop. This means that the compiler cannot find the definition of menuItem, and therefore cannot access its methods and attributes. This results in a compile-time error, which is an error that occurs when the source code is being translated into executable code. Compile-time errors prevent the program from running, and they need to be fixed before the program can be executed. In this case, the error can be fixed by changing menuItem to item in the three lines where it is used (or changing the item parameter to menuItem). This will make the code consistent with the for loop header, and allow the compiler to find the definition of item/menuItem. This will also enable the code to correctly print out the name, price, and description of each menu item in the menu array.

Jishan Shaikh  Sep 04, 2023 
Printed Page 437
1st paragraph

At the beginning of the first paragraph: "This is an overview of the five steps…".
There are only four steps.

Anonymous  Mar 16, 2021 
Printed Page 541
Bottom section in the `HeartTestDrive`

In the bottom section of the page, we assign the HeartController to a variable called 'model', I think this should read 'controller'?

current:

ControllerInterface model = new HeartController(heartModel);

proposed:

ControllerInterface controller = new HeartController(heartModel);

Edd  Mar 07, 2023