Errata for the 2nd Edition of Refactoring

One thing I can always accurately predict about my books is that I will make mistakes. Here are the ones I know about for the second edition of Refactoring. If you spot something I don't have listed, let me know. Errors are fixed in later printings.

Errors in 2nd and later printings

Page xix (Acknowledgments):

First paragraph, last sentence. "if we wasn't writing" should read "if he wasn't writing"

Page 27 (First Example: Splitting the phases of calculation and formatting):

At this point I can remove the plays parameter from renderPlainText, as it is now unused. I neglected to that while doing the refactoring, however, so it continues to show up later on.

Page 54 (What do I tell my Manager?):

In the final paragraph on the page, "I've certainly seen places were refactoring…" should read "I've certainly seen places where refactoring…

Page 96 (Building Tests: probing the boundaries):

In the code example the line

  name: "no proudcers"

should read

  name: "no producers"

Page 127 (Change Function Declaration):

In last paragraph of Simple Mechanics section, "I want to rename the a changeAddress" should read "I want to rename the a  changeAddress

Page 149 (Combine Functions into Transform):

In second paragraph of motivation, "Then, to examine the derivations, all I need do" should read "Then, to examine the derivations, all I need to do"

Page 155 (Split Phase):

Second paragraph, "It's a basic task is to take" should read "It's a basic task is to take"

Page 210 (Move Field):

In the second code example, the line this._setDiscountRate(discountRate) should be the last line of the constructor if I'm showing the state of the code after performing Slide Statements

Page 214 (Move Statements Into Function):

In the code example, the function renderPerson has a parameter outStream which isn't used in the body of the function. This makes the example more confusing than it should be, and can be safely ignored.

Page 219 (Move Statements to Callers):

Second line of second paragraph. "cut last line from renderPerson" should read "cut last line from emitPhotoData"

Page 224 (Slide Statements):

In the code example, the function retreiveOrder should be spelled retrieveOrder

Page 248 (Replace Derived Variable with Query):

In the last sentence of the first paragraph "I do advocate minimizing the scope of mutable data at much as possible" should read "I do advocate minimizing the scope of mutable data as much as possible."

Page 253 (Change Reference to Value):

In the line above the last code sample, "enhance the constructor to call the setters" should read "enhance the constructor to set these fields"

Page 291 (Introduce Special Case):

Fourth line from bottom, "But if I change the customer class" should read "But if I change the site class"

Page 360 (Push Down Method):

The step "Remove the method from each superclass that doesn't need it" should read "Remove the method from each subclass that doesn't need it"

Page 361 (Push Down Field):

In sketch I have the access modifiers the wrong way around. The before part should be "protected String quota" and the after should be "private String quota"

Page 364 (Replace Type Code with Subclasses):

Middle of page. "The employee subclass is simple" should read "The engineer subclass is simple"

Page 371 (Remove Subclass):

Fourth line from top. "When it comes to creating subclasses…" should read "When it comes to removing subclasses…"

Errors in the 1st printing

Page xix (Acknowledgments):

First paragraph, last sentence. "if we wasn't writing" should read "if he wasn't writing"

Page 2 (First Example: Starting Point): First sentence: "Image a company of theatrical players" should read "Imagine a company of theatrical players" [Corrected in the 2nd printing]

Page 27 (First Example: Splitting the phases of calculation and formatting):

At this point I can remove the plays parameter from renderPlainText, as it is now unused. I neglected to that while doing the refactoring, however, so it continues to show up later on.

Page 32 (First Example: Status: Separated into Two Files (and Phases)):

In the code, the line

function renderPlainText(data, plays)

should read

function renderPlainText(data)
[Corrected in the 2nd printing]

Page 39 (First Example: Making the Performance Calculator Polymorphic): First line, "createPerformanceData" should read "createStatementData" [Corrected in the 2nd printing]

Page 43 (First Example: Status: Creating the Data with the Polymoprhic Calculator): Second paragraph: "createPerformanceData" should read "createStatementData" [Corrected in the 2nd printing]

Page 54 (What do I tell my Manager?):

In the final paragraph on the page, "I've certainly seen places were refactoring…" should read "I've certainly seen places where refactoring…

Page 68 (Principles: Automated Refactorings): In the second paragraph of the section "Brandt" should be spelled "Brant". (Sorry John, I seem to have a persistent blind spot with your name.) [Corrected in the 2nd printing]

Page 81 (Smells: Middle Man): Second paragraph, all text after "If there is additional behavior" should be deleted. [Corrected in the 2nd printing]

Page 96 (Building Tests: probing the boundaries):

In the code example the line

  name: "no proudcers"

should read

  name: "no producers"

Page 127 (Change Function Declaration):

In last paragraph of Simple Mechanics section, "I want to rename the a changeAddress" should read "I want to rename the a  changeAddress

Page 135 (Encapsulate Variable): 3rd paragraph from bottom. "Now, any attempt to reassign the properties of the default owner will cause an error" should read "Now, any attempt to reassign the properties of the default owner will be ignored" [Corrected in the 2nd printing]

Page 142 (Introduce Parameter Object): Just above the last code sample. "adjust it to pass in the correct date range" should read "adjust it to pass in the correct temperature range" [Corrected in the 2nd printing]

Page 149 (Combine Functions into Transform):

In second paragraph of motivation, "Then, to examine the derivations, all I need do" should read "Then, to examine the derivations, all I need to do"

Page 155 (Split Phase):

Second paragraph, "It's a basic task is to take" should read "It's a basic task is to take"

Page 158 (Split Phase): In the 5th line of code, discount: discount should be highlighted [Corrected in the 2nd printing]

Page 162 (Encapsulate Record):

The first paragraph of the motivation section seems to have snuck off for a crafty pint in a local bar. It should read as follows:

Record structures are a common feature in programming languages. They provide an intuitive way to group related data together, allowing me to pass meaningful units of data rather than loose clumps. But simple record structures have disadvantages. The most annoying one is that they force me to clearly separate what is stored in the record from calculated values. Consider the notion of an inclusive range of integers. I can store this as {start: 1, end:5} or {start: 1, length:5} (or even {end: 5, length:5}, if I want to flaunt my contrariness). But whatever my store, I want to know what the start, end, and length are.

[Corrected in the 2nd printing]

Page 210 (Move Field):

In the second code example, the line this._setDiscountRate(discountRate) should be the last line of the constructor if I'm showing the state of the code after performing Slide Statements

Page 214 (Move Statements Into Function):

In the code example, the function renderPerson has a parameter outStream which isn't used in the body of the function. This makes the example more confusing than it should be, and can be safely ignored.

Page 219 (Move Statements to Callers):

Second line of second paragraph. "cut last line from renderPerson" should read "cut last line from emitPhotoData"

Page 224 (Slide Statements):

In the code example, the function retreiveOrder should be spelled retrieveOrder

Page 248 (Replace Derived Variable with Query):

In the last sentence of the first paragraph "I do advocate minimizing the scope of mutable data at much as possible" should read "I do advocate minimizing the scope of mutable data as much as possible."

Page 251 (Replace Derived Variable with Query): Last paragraph, "I'd be inclined, however, to leave totalProductionAjustments..." should read ""I'd be inclined, however, to leave calculatedProductionAccumulator..." [Corrected in the 2nd printing]

Page 253 (Change Reference to Value):

In the line above the last code sample, "enhance the constructor to call the setters" should read "enhance the constructor to set these fields"

Page 263 (Consolidate Conditional Expression): In sketch, and code example at top of page 265. "isNotEligableForDisability" should be "isNotEligibleForDisability". (I originally made this error in the first edition, fixed it in the errata, and reintroduced it when writing the second.) [Corrected in the 2nd printing]

Page 291 (Introduce Special Case):

Fourth line from bottom, "But if I change the customer class" should read "But if I change the site class"

Page 295 (Introduce Special Case): Top paragraph, "I should be able to use Remove Dead Code on the global isPresent function" should read "I should be able to use Remove Dead Code on the global isUnknown function" [Corrected in the 2nd printing]

Page 360 (Push Down Method):

The step "Remove the method from each superclass that doesn't need it" should read "Remove the method from each subclass that doesn't need it"

Page 361 (Push Down Field):

In sketch I have the access modifiers the wrong way around. The before part should be "protected String quota" and the after should be "private String quota"

Page 364 (Replace Type Code with Subclasses):

Middle of page. "The employee subclass is simple" should read "The engineer subclass is simple"

Page 371 (Remove Subclass):

Fourth line from top. "When it comes to creating subclasses…" should read "When it comes to removing subclasses…"

Page 405 (Bibliography): The ISBN for the [gof] reference should read 0201633612 [Corrected in the 2nd printing]


Many thanks to Jeff Xiong, Umang Bhatt, Gautier Hayoun, Congyu Lin, Dmytro Pavliuchenko, Linhao Li 李霖灏, Ty Lewis, Akira Hirasawa, Masao Tomono, Kiminobu Kodama, Christopher Wheeler, Ondrej Kvasnicka, David Stevenson, Vincent Petit, Jeff Bingaman, David Bausela, and Ben Forshey for spotting and telling me about these errors