Errata

If you find a mistake in the book, first let me offer you my apologies.

Second, if you have the time, please drop me a line at russ at russolsen.com with the page number and a quick description of the problem. If you take the trouble to report the problem I will include it in the errata page here and will fold it into the paper book at the first possible opportunity. I will also thank you by name, so make sure you spell you name right!

Here are the out-and-out mistakes that have turned up since the book was published. Most of these have been fixed in the most recent printing.

  • Overall

    Somehow I managed to go on for 300+ pages without ever once mentioning that I was using Ruby 1.8.6 to run all of the code. If 1.8.6 sounds absolutely ancient to you, take heart: I’ve updated the example code to run with Ruby 2.1 and the changes were minimal.

  • Preface / Page xxii

    The final line of code on this page is missing some parentheses. The correct version is:

    (divisor == 0) && puts('Division by zero')
    
  • Preface / Page xxiii

    The logic in the final line of code on this page is incorrect. The correct version is:

    file.eof? && puts('Reached end of file')
    
  • Chapter 1 / Page 12

    The example at the bottom of the page would probably be better if the sunday_drive method called the start_engine and stop_engine methods instead of using @engine directly.

  • Chapter 2 / Page 32

    The example of the for loop at the bottom of the page would be much improved if it included an actual for loop. The proper code is:

    array = ['first', 'second', 'third']
    
    for element in array
      puts element
    end
    
  • Chapter 2 / Page 47

    The text just before the code example mentions the Account class. This should be the BankAccount class.

  • Chapter 3 / Pages 66 and 67

    In the code examples at the bottom of pages 66 and 67, the output_report method should call the output_body_start and output_body_end methods.

  • Chapter 3 / Page 68

    The sentence just before the code example references a variable called formatter. It should be report.

  • Chapter 3 / Page 70

    The last line on the page should read “…languages go to in order to avoid even the remote possibility of type errors.”

  • Chapter 4 / Page 80

    The third line of the second paragraph should read, in part, “…we might have used…”

  • Chapter 4 / Page 89

    There is an ‘end’ missing from the code example in the middle of the page.

  • Chapter 4 / Page 89

    Using a for the name of the array and also the block parameter is probably not the best choice.

  • Chapter 6 / Pages 96-97

    In the code examples the title attribute is sometimes read only and sometimes read-write.

  • Chapter 5 / Pages 99-100

    The sample output should report Fred’s new salary as 90000.0, not 80000.0 as shown incorrectly in the book. So much for stone age accounting.

  • Chapter 5 / Page 100

    The class in the lower right of the UML diagram is incorrectly labeled Employee. It should be either Payroll or TaxMan.

  • Chapter 5 / Page 103

    The last sentence in the footnote incorrectly says that calling super without an argument list will result in the super class method being called with the parameters name, title, salary and payroll_manager. In fact, since payroll_manager is not part of the original argument list it would not be passed by any call to super.

  • Chapter 5 / Page 105

    Although not strictly a typo, it would have been better if I had noted that the observer added in the second code example can’t be removed because the code does not save a reference to the observer.

    Also the code example at the top of the page would be clearer if salary was declared with an attr_reader.

  • Chapter 5 / Page 107

    There is an extraneous changed = true assignment in the first code example on this page.

  • Chapter 5 / Page 107

    The first sentence on this page should say that the interface can be as complex as you like.

  • Chapter 6 / Pages 113

    The last sentence of the first paragraph should read “one for each basic job:”

    Also there are references on this page to MakeBatter which should be MakeBatterTask.

  • Chapter 6 / Pages 122

    The name of the method in the last sentence on this page is incorrect. The correct method name is total_number_basic_tasks.

  • Chapter 7 / Page 131

    The class name ArrayIterator is misspelled in the last paragraph on this page.

  • Chapter 7 / Page 134

    In the last bit of code on this page there is an unfortunate space between the > and the =.

  • Chapter 8 / Page 143

    There is one thing too many in the last sentence on this page.

  • Chapter 8 / Page 149

    The last code example on this page should include require 'fileutils'.

  • Chapter 8 / Page 152

    The sentence below first code sample should read “its name suggests”.

  • Chapter 8 / Page 153

    The code at the top of the page includes an unneeded variable f.

  • Chapter 8 / Page 154

    The second to last sentence on this page is missing a “that”.

  • Chapter 8 / Page 156

    The first complete sentence on this page is missing an “is”.

  • Chapter 8 / Page 159

    The DeleteEmployee.execute method, should call system.delete_employee(@number) not system.add_employee(@number).

  • Chapter 10 / Page 181

    The s variables in the code on this page are not really necessary.

  • Chapter 10 / Page 188

    The s variable in the code at the bottom of this page is not really necessary.

  • Chapter 10 / Page 190

    In the middle of the page, the kind of athletics that your code should not require are mental, not metal.

  • Chapter 10 / Page 190

    The last second to last sentence on this page features an extra “a”.

  • Chapter 11 / Page 194

    In the first line of the timestamp method, the %{@line_number} should be #{@line_number}.

  • Chapter 11 / Page 195

    The first sentence of the third paragraph from the bottom of the page has a bonus “a”.

  • Chapter 11 / Page 199

    The initialize method of CheckSummingWriter should call super.

  • Chapter 11 / Page 201

    The last sentence of the second paragraph refers to @component when it really means @real_writer.

  • Chapter 11 / Pages 201-203

    The text refers several times to an non-existent write method. The correct method name is write_line.

  • Chapter 11 / Pages 203

    The Writer class is unnecessary.

  • Chapter 11 / Pages 205

    The first sentence on this page should say that you can find a good example in ActiveSupport.

    Also the last sentence should say that you cannot simply un-extend a module.

  • Chapter 12 / Pages 220

    The second sentence should say that the clone method is a wonderful utility.

  • Chapter 12 / Pages 222

    The second code example includes an unneeded preferences varaiable.

  • Chapter 14 / Page 252 and 254

    In the code examples, the has_turbo_cpu parameter of the turbo method is unused.

  • Chapter 14 / Page 256

    In Figure 14-2, the uppermost horizontal arrow head should be solid: A Director is not an instance of a ComputerBuilder; rather it has a reference to a ComputerBuilder.

  • Chapter 14 / Page 256

    In Figure 14-2, the labels “Desktop Computer” and “Laptop Computer” are reversed.

  • Chapter 14 / Page 258

    In the last sentence on this page, “method” should be singular.

  • Chapter 14 / Page 259

    In the first paragraph of the Using and Abusing the Builder Pattern it’s a builder that starts to make more sense.

  • Chapter 15 / Page 271

    The second non-code sentence from the bottom of the page should read:

    With Or we can find all of the files that are either MP3s or bigger than 1K in one shot:

  • Chapter 15 / Page 274

    The first paragraph on this page talks about a parse method. It is actually the expression method.

  • Chapter 15 / Page 276

    The first code snipet refers to a file_name method. It is actually file.

  • Chapter 16 / Page 289

    There is an extra this in the first sentence.

    The last paragraph refers to Source which is actually DataSource.

  • Chapter 17 / Page 302

    The Frog class mentioned in the last paragraph should be a Tree.

  • Chapter 17 / Page 305

    The text at the bottom of the page says that the three methods are created by member_of. In fact, they are created by composite_of.

  • Chapter 17 / Page 310

    There is one animal too many in the last sentence on this page.

  • Chapter 18 / Pages 317

    Also the Message initialize methods should convert the to parameter to a URI.

  • Chapter 18 / Pages 318-319

    Several of the code examples on these pages refer to a non-existent message.text attribute. The correct name is message.body.

    Also the adapters on this page define a send method instead of the correct send_message method.

  • Chapter 18 / Page 321 The first paragraph should refer to require statements.

  • Chapter 18 / Page 325

    In the third paragraph, second line, the last word should be authorized?.

  • Chapter 18 / Page 326

    In the code example, the File.join should read:

    file_name = File.join('lib', 'adapter', "#{protocol_name}_adapter.rb")
    
  • Chapter 18 / Page 327

    In the middle of the page it would be more correct to say that russolsen.com would be transformed into RussolsenDotCom.

  • Chapter 18 / Page 328

    The 2nd bullet on the page refers to the Rails view directory. The correct directory name is plural: views.

  • Chapter 18 / Page 328

    The first sentence of the third bullet should read “Rails applications typically use ActiveRecord to talk to the database.”

Many thanks to the following for pointing out these problems:

  • Sam Aaron,
  • Gus Gollings
  • Jan Goldenbaum
  • Dean Holdren
  • John Hohlen
  • Jochen Hayek
  • Gary L. Johnson
  • Michael Nah
  • Glenn Ritz
  • Brian Uri
  • Juri Vainonen
  • Howard Wong
  • The French translation team of Laurent Julliard, Mikhail Kachakidze and Richard (with an ‘i’) Piacentini
  • The Japanese translation team, especially Yumeto Yamagishi and Yutaka Sugano
  • Sagar Pandya
  • Angelos Orfanakos

And a special meta thanks to Angelos Orfanakos for pointing out typos on this errata page.