Errata

Learning PHP Design Patterns

Errata for Learning PHP 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
ePub Page 15
1st paragraph under "Abstract Classes" subtitle

(one your can instantiate)

Should be

(one you can instantiate)

Anonymous  Dec 11, 2012 
Printed Page 23
3rd paragraph, last sentence.

The last sentence contradicts what was said previously in the paragraph. It should say "However, *a concrete* class can consist of nothing but concrete methods."

Stuart Maynes  Mar 30, 2013 
Printed Page 25
2nd paragraph

"[...] in addition to implementing the three methods [...] the [...] class includes a third method [...]." should read "[...] in addition to implementing the three methods [...] the [...] class includes a fourth method [...]."

Carsten Dietzel  Jan 11, 2016 
PDF Page 32
3rd paragraph

The sentence "Of course, all constructor methods are public" is false. If perfectly feasible to have a class with a private constructor or protected constructor.

joan llosas  Mar 11, 2013 
Printed Page 51
Last sentence that ends with a colon

I believe methods should be substituted for classes in the following sentence:

The Client class instantiates the InheritMath class and is able to use all of the functionality inherited from the DoMath class as well as the included classes for text work:

Anonymous  Dec 07, 2014 
Printed Page 60
Figure 4.1

The text before this figure 4.1 claims that interfaces are written in italics, and that concrete classes are in bold Roman text. I can see absolutely no difference in these classes. They're all in bold. If some are supposedly in italics then they are so slight that they are indistinguishable from anything else.

Anonymous  Apr 23, 2020 
Printed Page 63
Last paragraph

The first paragraph of "Relationship Notations" is the same as the last of "Participant Symbols" ("Pseudocode annotations provide further information..."). The actual first paragraph of "Relationship Notations" seems to be missing.

Carsten Dietzel  Jan 12, 2016 
Printed Page 66
First paragraph of Aggregation Relationship

In the middle of this paragraph there is this "... aggregation implies that an aggregate object and its owner have identical lifetimes." Every other reference I find says that in aggregation relations the dependent object is independent and can live after the containing object is deleted.

Wyckham Seelig  Dec 05, 2022 
Printed Page 67
Last paragraph of page

The last line of this paragraph says that "For example, a client making a request would include a ConcreteStrategyA:"

This looks like the text will actually show the client code, but instead all we see on the next page is the code for the Interface.



















































































Wyckham Seelig  Dec 05, 2022 
Printed Page 68
Second paragraph

I came up with this explanation of the difference between composition and aggregation and wonder if it is even close to being correct:

In compositions, the dependent object is generally instantiated as a property inside its container, and dies when the container dies.

In aggregations, the dependent object is generally instantiated independently of the container and is usually passed in as an argument to the container's constructor. Because the dependent object is instantiated independently of the container it can live on after the container dies.

Wyckham Seelig  Dec 05, 2022 
Printed Page 81-83
Last but one sentence under the heading "A Mimimalist Example"

Unclear sentence: "one displaying ... and the other ..."
"One" What? "The other" WHAT?
(The beginning of the sentence talks about *one* single design.)

In general, the text is hard and time-consuming to follow and absorb because of linguistical errors like these. I have only (tried to) read chapter 5 Factory Method Design Pattern and after I kept noticing quite a few linguistical deficiencies, I had to give up reading the chapter.

Another example is on the top of page 82:
A PHP variable $mfg suddenly appears. It has not been declared; it is not explained in the text; the variable's name 'mfg' is not self-explanatory.

Another example appears on the bottom page 83:
"This next implementation returns an abstract graphic in a message with a 'text graphic' "
I have absolutely no idea of what information that sentence is trying to convey!

widheg  Sep 21, 2017 
PDF Page 85
line 10, first bloc of code

Following the HTML5 dradt from w3 the doctype declaration consists of "A string that is an ASCII case-insensitive match for the string "<!DOCTYPE"."

So, the code <!doctype html> is invalid.

joan llosas  Mar 11, 2013 
PDF Page 91
Creator.php, after 2nd paragraph

The method doFactory is stated in text below as startFacrory.

What is $countryProlduct for and why copy $productNow first and then assigning it to factoryMethod?

Anonymous  Apr 01, 2013 
Other Digital Version 91
"The New Factories", 2nd Paragraph

The paragraph states "both the factoryMethod() and the startFactory() operations expect a parameter." The code snippet does not have a startFactory() method. It should be doFactory(). This is the Kindle version of the book as of December 25, 2021.

Anonymous  Dec 25, 2021 
PDF Page 94
last line

method named addTop

This name is very confusing since it adds anything to the top of anything. The name has nothing to do with what the method is doing: returning a string with the tags of an html head. Wouldn't be very much useful to name such a method, for example, getHeadTags() or getTopTags()

joanllosas  Mar 13, 2013 
PDF Page 96
Figure 5-6

MailProduct.php must be MaliProduct.php

joanllosas  Mar 13, 2013 
Printed Page 101
The PHP code

It is confusing to name a class "CloneMe". Classes should be named as nouns, not verbs.

widheg  Sep 21, 2017 
PDF Page 107
function showFLy

$genderNow=$fly::gender;

should by :
$genderNow=$fly->gender;

KLAKS5G  Feb 10, 2014 
Printed, PDF Page 109
Last paragraph (non-Code).

Sentence begins, "Not that all of the properties are protected...". It should read, "Note that all of the properties are protected." Further suggestion, this is a comma splice, and therefore it is recommended to revise the sentence to: "Note that all of the properties are protected. So even though the concrete getters and setters have public visibility, the protected visibility of the properties used in the operations affords a degree of encapsulation:".

Joshua Eldridge  Feb 14, 2014 
PDF Page 115
function showEmployee()

echo $employeeNow->getDept().": " . $employeeNow::UNIT . "<br/>";

should by:

echo $employeeNow->getDept().": " . $employeeNow->UNIT . "<br/>";

Klaks5G  Feb 10, 2014 
PDF Page 131
2

see:
private function makeAdapterRequest(ITarget $req)
{
return $req->requestCalc(40,50);
}

function requestCalc() is not defined in interface iTarget.
So, this type hinting is confusing for me.
Example works fine. But i thing because of PHP is not strong typed language.
Bru.

Anonymous  Apr 11, 2013 
PDF Page 142
Figure 8-1

Decorator name must be in italic as said in the text: "Decorator is one of the few design patterns that includes one abstract
class inheriting another abstract class". Abstract classes are rendered in italic.

joan llosas  Mar 13, 2013 
Printed, PDF, ePub Page 146
Last paragraph

The first sentence of the last paragraph reads, "If you look at the concrete constructor, you will see that it looks almost identical to the decorators."

I believe the author likely meant ... "If you look at the concrete component, you will see that it looks almost identical to the decorators."

The following adversative sentence seems to corroborate this: "However, each of the concrete decorators adds its own value to the value of the concrete COMPONENT it wraps."

Joshua E.  Jan 30, 2014 
PDF Page 147
2

"class Video extends IComponent"
should be
"class Video extends Decorator"

Bru  Apr 20, 2013 
PDF Page 155
2

$this->ageGroup=$this->ageGroup;
should be
$this->ageGroup = $ageNow;

Bru  Apr 21, 2013 
PDF Page 163
bottom of page

private $progLange;
should be
private $progLang;

Bru  Apr 24, 2013 
PDF Page 182
bottom of page - HTML listing

</head> tag is missing

Bru  Apr 26, 2013 
PDF Page 222
code sample IConnectInfo.php

Saving connection data to a database in an interface is a very bad idea. This bad idea begins with the false assumption that this data is constant. And this data is not constant! The pattern to use in those situations is Dependency Injection, badly not explained in this book. Mi?ko Hevery, quoted in some places in the book, talks a lot about DI in his blog (http://misko.hevery.com/).

* In development, if I have database with real data and database with trash data for testing. How do I switch between databases? I must change the name of the file where the interface sits, perhaps putting and _ in front of it, and then, in another file, remove some characters to change the name to the usable one.
* In a situation where I have a database user for showing data to not logged users and another database user for privileged access for logged users. I can't change the interface to which database is coupled. I must create a new interface with the data, and then I must duplicate all the Connection clase, implementing the new interface?
* If I log errors in a special database and I work with another database. I need two different connections, each one to a database. But, how can I do that if the class of the connection is coupled to an interface that doesn't allow me to change connection data?
* I work in development environment. I sent code to production. The guy here must find between all php stuff where is connection data, and the he must touch code of an interface. If he knows nothing about php and removes an ", then all crashes.
* If I have a version control system, and I version all the code, I include very sensible information, such as connection data, which is a very bad idea. If I omit the interface (adding it to .gitignore or similar), then, when I clone the repository a piece of code is missing...

joan llosas  Mar 14, 2013 
PDF Page 224
top of page

to execute
$this->hookup=UniversalConnect::doConnect();
without errors

we need add static keyword to pg. 222 i.e.
interface IConnectInfo
{
...
public static function doConnect();
}

and to pg. 223 i.e.
class UniversalConnect implements IConnectInfo
{
...
public static function doConnect()
...
}

Bru  May 10, 2013 
Printed, PDF, ePub Page 225
Top of Page

To fix the following error:

Fatal error: Non-static method UniversalConnect::doConnect() cannot be called statically, assuming $this from incompatible context in...

You must change the constructor in ConnectClient to:

$this->hookup = new Connect();
$this->hookup->doConnect();


UniversalConnect::doConnect() is the old PHP4 style which is no longer valid.

Francisco Mateo  Jul 28, 2014 
PDF Page 265
Top

The name of the ConcreteStrategy DisplayData changes through the chaper to DisplayAll.

DisplayData appears on pages 244, 248, and 249. It also appears in the diagram at the beginning of the chapter on page 243.

Beginning on page 252, this ConcreteStrategy referred to as DisplayAll. It also appears on pages 261 and 265.


jean claude a-dam  Oct 03, 2013