Errata

C++ Software Design

Errata for C++ Software 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. 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
Page Page 226-227
operator<< and l2norm

DynamicVector const<T>& should be DynamicVector<T> const&. (2 places)

Note from the Author or Editor:
The finding is correct: in two places (one on pages 226 and one on page 227) the const should following the '<T>'. The fix has been merged into the repo on February 10th, 2023.

Yung-Hsiang Huang  Feb 10, 2023  Dec 08, 2023
Page Page 355
Figure 9-6

CppBook should just be “class CppBook” not “class class CppBook”.

Note from the Author or Editor:
Figure 9-6 needs to be updated, "class class CppBook" should be replaced with "class CppBook".

Tomer Tzadok  Mar 14, 2023  Dec 08, 2023
Page pg 111 "Be Aware of the Design Choice in Dynamic Polymorphism
2nd Paragraph

The quote:

Correct, start of paragraph
"The strength of object oriented programing is the easy addition of new types, but its weakness is that the addition of operations becomes much more difficult. ... "

Continued:
"It depends on the project: if you expect new types will be added frequently, rather than operations, you should strive for an """"OCP"""" solution which treats operations as a closed set and types as an open set. If you expect operations will be added, you should strive for a procedural solution which treats types as a closed set and operations as an open set"


The typo is that OCP (open closed principle) should actually be OOP (object oriented programming). In the start of the paragraph, reproduced above, it is explained that OOP adds types easily, and previously in the chapter contrasts OOP and procedural solution. By context, OOP in comparison with procedural makes more sense than OCP in comparison with procedural.

Note from the Author or Editor:
The erratum is correct: "OCP" should be "OOP". This erratum has already been fixed in the repo.

Christopher Apple  Dec 05, 2023 
Page 7. Improving Performance with Partial Bridges
//---- <Person3.h> ----------------

Error:
class Person3
{
//...

private:
// ...
struct Impl;
std::unique_ptr<Pimpl> pimpl_; // 'Pimpl' template param should be 'Impl'
};

Correct
class Person3
{
//...

private:
// ...
struct Impl;
std::unique_ptr<Impl> pimpl_;
};

Note from the Author or Editor:
Thanks a lot for taking the time to submit this error. Yes, the 'Pimpl' in the std::unique_ptr should be an 'Impl'. This will be fixed in the next release of the book.

Edit: The fix has been committed to the repository.

Seth Kohler  Nov 25, 2022  Dec 08, 2023
Page 21
Code sample

The constructor of CppBook takes 3 arguments but is only given 2.

Note from the Author or Editor:
The finding is correct: in the code example on page 21 the CppBook instances should take three arguments instead of just 2. The fix is either to change the constructor of the CppBook class to only take two parameters or to fix and reformat the code example to pass 3 parameters.

Brian Gloyer  Mar 07, 2023  Dec 08, 2023
Page 40
inside some_function(T& value) body comment

using std::swap // Enable the compiler to consider std::swap for the subsequent call

The comment here is confusing as in next statement, swap from custom namespace gets called but the comment gives the impression that its std::swap getting called. It should be something like :
Enable the compiler to consider std::swap for the subsequent call if ADL didn't find any swap in the namespace where template argument value came from

Note from the Author or Editor:
The suggested fix may help a little to avoid confusion, but increases the length of the code by at least two lines. Thus this should be considered only when also taking care of the page layout.

Rajiv Saxena  Dec 04, 2022  Dec 08, 2023
Page 51
1st paragraph from bottom

Error:
template< std::forward_iterator ForwardIt, std::forward_iterator ForwardIt >
OutputIt copy( ForwardIt first, ForwardIt last, ForwardIt d_first );

Possible solution:
template< std::forward_iterator ForwardIt, std::forward_iterator OutputIt >
OutputIt copy(ForwardIt first, ForwardIt last, OutputIt d_first);

Note from the Author or Editor:
Thanks for taking the time to report this error. Yes, you are correct, the copy function should take two different kinds of iterators. The example should be like this:

template< std::forward_iterator ForwardIt >
OutputIt copy(ForwardIt first, ForwardIt last, ForwardIt d_first);

I apologize for this oversight. This error will be fixed in the next print of the book. Thanks again,

Best regards,
Klaus!

Edit: The fix has been committed to the repository.

Florin Ioan Dr. CHERTES  Nov 28, 2022  Dec 08, 2023
Page 59
Line 4 of Footnote 13

According to author’s webpage, martinfowler.com/books/refactoring.html, the refactoring book’s 1st edition was published in 1999, not 2012.

Note from the Author or Editor:
The finding is correct: the first edition of Martin Fowler's "Refactoring" was published in 1999, not 2012. This should be fixed in the next printing of the book.

Yung-Hsiang Huang  Feb 12, 2023  Dec 08, 2023
Page 82
Figure 3-1

`ConcreteStrategyA` appears twice instead of `ConcreteStrategyA` and `ConcreteStrategyB`

Note from the Author or Editor:
Figure 3-1 indeed contains the name 'ConcreteStrategyA' twice. The second/right name should be 'ConcreteStrategyB'.

Mateusz Fila  Feb 25, 2023  Dec 08, 2023
Page 88
The code snippet

auto strategy = std::make_unique_ptr<...
is an error/typo. It should be
auto strategy = std::make_unique<...

Note from the Author or Editor:
This is indeed a typo in a code example. The fix has already been merged into the repo.

Ivan Komarov  Jan 04, 2023  Dec 08, 2023
Page 94
Second to last paragraph

The word "pattern" should be changed to "patterns" in "There are even five design pattern if you [...]".

Note from the Author or Editor:
At the beginning of the four paragraph on this page, the word "pattern" should indeed be changed to "patterns".

Elene Trull  Sep 01, 2023  Dec 08, 2023
Page 110
Last paragraph, 3rd last line.

Change: recompile any "exiasting" code to: recompile any "existing" code

Note from the Author or Editor:
This typo has already been fixed in commit 46f17334.

Sukhraj Singh  Dec 30, 2022  Dec 08, 2023
Page 115
Figure 4-2

In the UML representation of the Visitor design pattern, Shape has a composition relation with ObjectStructure.

The relation should be the other way round (the filled diamond should be drawn at ObjectStructure). Shape is an abstract base class and does not have any attributes.

I interpret ObjectStructure to mean the container for the Shape objects. Maybe it would help if this fact was explained somewhere in the text or the figure caption.

Note from the Author or Editor:
The erratum is correct. The filled diamond should be at the "ObjectStructure" and the line should go towards the "Shape". This will have to be fixed in the next release of the book.

Andreas Schätti  Jul 24, 2024 
Page 134
Figure 4-5

accept(ShapeVisitor) should be accept(AbstractVisitor). (3 places)

Note from the Author or Editor:
All occurrences of 'ShapeVisitor' in Figure 4-5 should be replaced by 'AbstractVisitor'. The surrounding source code is correct.

Yung-Hsiang Huang  Mar 01, 2023  Dec 08, 2023
Page 134
Figure 4-5, lower box

The symbol > should be < in "auto cv = dynamic_cast>CircleVisitor8>(v);" (lower box inside Figure 4-5, below Circle class).

Note from the Author or Editor:
Figure 4-5 indeed contains a typo in the lower box. The line should be corrected as suggested:

"auto cv = dynamic_cast>CircleVisitor8>(v);"

should be

"auto cv = dynamic_cast<CircleVisitor8>(v);" (note the <)

Antonella Ritorto  Aug 24, 2024 
Page 146
Figure 5-3, OpenGLBoostSerialCircle

There is an extra 'n' in serializen()( -> serialize()).

Note from the Author or Editor:
Figure 5-3 indeed contains a "serializen()", which should be replaced by "serialize()".

Antonella Ritorto  Aug 24, 2024 
Page 155
Figure-5-6

Instead of DrawCircleStrategy should it not be DrawStrategy<Circle>
The code for the figure is correct.

Note from the Author or Editor:
Figure 5-6 should indeed contain DrawStrategy<Circle> instead of DrawCircleStrategy. Therefore this is a minor inconsistence between the image and the code example(s). This will have to be fixed before the next release of the book.

Sukhraj Singh  Dec 30, 2022  Dec 08, 2023
Page 169
Last paragraph, 2nd last line.

Instead of undo() function it should be undoLast() function.

Note from the Author or Editor:
This is a small inconsistency between the code examples and the accompanying text. The current sentence is:

"As a result, both compute() and undo() do not have to be virtual functions."

It should be

"As a result, both compute() and undoLast() do not have to be virtual functions."

Sukhraj Singh  Dec 30, 2022  Dec 08, 2023
Page 207
last paragraph

Missing "to" in the sentance:
... for some reason duck and turkeys are expected **to** be used together.

Note from the Author or Editor:
The sentence is indeed missing a 'to'. It needs to be added in the next re-print of the book.

Mateusz Fila  May 03, 2023  Dec 08, 2023
Page 221
Line 3 of 2nd paragraph

In “, since this a very reasonable next step”, the verb is lost. I suggest to change “this a” into “this is a”.

Note from the Author or Editor:
The sentence is indeed missing a verb. It should read "..., since this is a very reasonable next step."

Yung-Hsiang Huang  Feb 11, 2023  Dec 08, 2023
Page 225
Guideline 26, beginning of 5th sentence

Sentence starts with
"If you're' scratching your head"
there is an extra single quote ' after "you're"

Note from the Author or Editor:
Correct, there is an extra single quote after "you're". This needs to be removed in the next re-print.

Anonymous  May 22, 2023  Dec 08, 2023
Page 232
1st sentence of 3rd paragraph

"you were taking about" should be "you were talking about"

Note from the Author or Editor:
"taking" should be changed to "talking".

Tim Varelmann  Jul 26, 2023  Dec 08, 2023
Page 247
Box for guideline 27

In the first bullet point:

'Be aware between the difference...'

should be changed to:

'Be aware of the difference...'

Note from the Author or Editor:
The errata is correct, the bullet point should read "Be aware of ...". The fix has been merged into the repository on July 30th.

Andreas Schätti  Jul 29, 2024 
Page 259
Code block of Person.h

Based on the previous codeblock, the import part should not been comment out.

So,
```
//#include <memory>
```
Should be
```
#include <memory>
```

This can also apply to the next page's "Person.cpp" block, where
```
//#include <Person.h>
//#include <string>
```
Should be
```
#include <Person.h>
#include <string>
```

Note from the Author or Editor:
The finding is correct: All three mentioned includes are incorrectly commented out. These comments should be removed.

Jianming Xiao  Sep 19, 2023  Dec 08, 2023
Page 270
Table 7-2 header

Isn't Table 7-2 heading should be for compilers GCC11.1 and Clang 11.1 as in Table 7-1 ?

Note from the Author or Editor:
It is correct that the headings for Table 7-1 and 7-2 are different. Once the book is in reprint, these headings will have to be checked again and will have to be adapted.

Rajiv Saxena  Jan 16, 2023  Dec 08, 2023
Page 274
Figure 7-5

In the figure 7-5, it has an arrow at the top which associate with text "Engine". In the original picture of GoF book (page 119), this text should be "prototype".

Note from the Author or Editor:
This finding is correct: the arrow should be labeled with "prototype" instead of "Engine". This seems to be a copy and paste error from other images.

Jianming Xiao  Sep 19, 2023  Dec 08, 2023
Page 330
bullet 26

Remove * from (*model->drawer_).

This is according to khayk’s github commit: github.com/igl42/cpp_software_design/commit/4dd414066413a432a8d19d86ea7a7e60257d5a3e

Note from the Author or Editor:
The reported error and the suggested fix are correct: the "*" needs to be removed. The fix has already been merged into the repo.

Yung-Hsiang Huang  Mar 05, 2023  Dec 08, 2023
Page 331
Copy constructor in the code snippet

pimpl_(clone_(…), …) should be pimpl_(other.clone_(…), …) since clone_ is uninitialized when we initialize the unique_ptr pimpl_. The official github file G33_Small_Buffer_Optimization.cpp also supports this fix.

Note from the Author or Editor:
The finding is correct, the code example needs to be updated. The fix has already been merged into the repo on March 8th.

Yung-Hsiang Huang  Mar 07, 2023  Dec 08, 2023
Page 365
Body of grossPrice()

taxer_.applyTax(item_.price()) should be taxer_->applyTax(item_->price()). That is, change “.” to “->”. (2 places)

Note from the Author or Editor:
This error has already been fixed in the repo: both "." have been replaced with "->" (taking also care of special characters).

Yung-Hsiang Huang  Mar 05, 2023  Dec 08, 2023
Page 370
Figure 9-7

The order of template arguments of the class Discounted should be exchanged. (Cf: the code snippet in Page 368.)

Note from the Author or Editor:
The template arguments in Figure 9-7 indeed need to be changed. This will have to be done before the next reprint of the book.

Yung-Hsiang Huang  Jan 05, 2023  Dec 08, 2023
Page 381
last paragraph

is 'onlhy', should be 'only'

Note from the Author or Editor:
This typo has been fixed in the repo on February, 26th.

Mateusz Fila  Feb 25, 2023  Dec 08, 2023
Page 463
3rd paragraph

Error:

template< typename DocumentT >
class DocumentModel
{
public:
// ...


Correct:

template< typename DocumentT >
class DocumentModel : public DocumentConcept
{
public:
// ...

Note from the Author or Editor:
Thanks a lot for taking the time to submit this error. You are correct, the 'DocumentModel' should inherit from the 'DocumentConcept'. This will be fixed in the next release of the book.

Edit: The fix has been committed to the repository.

Florin Ioan Dr. CHERTES  Nov 25, 2022  Dec 08, 2023