Industrial Logic -> Refactoring to Patterns -> Errata

Errata for Refactoring To Patterns

If you find an error in the book, please email the details to Joshua Kerievsky. Below you will find errors/omissions discovered in different printings of the book.

1st And 2nd Printings

xxvi Please add "Benny Sadeh" to the list of names in the 3rd paragraph. THis was almost fixed -- it was added to the last paragraph on the page instead of the 3rd (which begins with "The following folks also..."). [Awaiting correction in 4th printing]

p14: Should read "while the rest of the class watches", not classes [Corrected in the 2nd Printing]

p61: At the top of the page, the parameter "customerRating" appears twice -- it should actually be called riskRating, not customerRating. [Corrected in the 3rd Printing]

p71: A space is missing between ,the in the middle of the page. [Corrected in 2nd Printing]

p93: In step 1, where it says protected OutputBuilder createBuilder(String rootName), it should actually say private OutputBuilder createBuilder(String rootName) (In other words, change the word protected to private). Thanks to Andreas Kemkes for pointing this out. [Corrected in the 3rd Printing]

p94: In step 4, the second line of code should be in bold: protected OutputBuilder builder; [Corrected in 2nd Printing]

p114: In the "before" sketch, there should be a dotted line connecting the "play(): void" in the "Backjack" box with the comment box that contains the words "hitStayResponse = " Thanks to Tomohiro Takahashi for spotting this. [Corrected in the 3rd Printing]

p132: The paragraph that begins with the words "A Challenge of following this approach..." should be indented so that it is part of item b. [Corrected in the 3rd Printing]

p132: In the last line of item a., package projection access should be package protection access. [Corrected in the 3rd Printing]

p134: At the top of the page, the box that says RevolverRiskAdjustedCapital should have a horizontal line coming out of it that connects to the line for the TermLoanRiskAdjustedCapital. [Corrected in 2nd Printing]

p144: In the "before" sketch, there is a missing dotted line to connect the box with aStringNode to the comment box. In the "after" sketch, there is a missing dotted line to connect the box with aDecodingNode to the comment box. See Move Embellishment to Decorator sketch [Corrected in 2nd Printing]

p144: There are two gray boxes on this page. The one on the right should read "Decorator: ConcreteComponent", not "Decorator:ConcreteDecorator". Thanks to Debbie Utley for pointing this error. [Corrected in the 3rd Printing]

p152: At the top of the page, there are two occurrences of STRING_TO_DECODE. Replace both occurences with the word "stringToDecode" which follows the Java naming convention. Thanks to Naoki Koguro for spotting this. [Corrected in the 3rd Printing]

p153: There are two minor errors on this page. In the middle of the page, there is an unnecessary blank line between the code that reads "public Node find(...) and the line that contains the text "..." In addition, there is a "..." that is mis-indented towards the bottom of the page. It should be aligned with the line of code beneath it, which reads "return new StringNode("ng] [Corrected in the 3rd Printing]

p156: The comment box at the bottom of this page should have a dotted line that connects it to the method toPlainTextString() : String. [Corrected in the 3rd Printing]

p166: At the bottom of this page, there should be a dotted line connecting the comment box with the claimedBy(...): void method. Go to Replace State-Altering Conditionals with State to see the what it should look like. [Corrected in the 3rd Printing]

p171: The state transition diagram at the bottom of page 171 contains an oval with the words "System Permission" -- the text in that oval should actually say "System Permission Granted" [Corrected in the 3rd Printing]

p179: "Toy Porshe" should be "Toy Porsche" [Corrected in the 3rd Printing]

p205: In the "before" sketch, there is a missing dotted line from the capital method in the CapitalStrategyTermLoan box to the comment box. See Form Template Method sketch [Corrected in 2nd Printing]

p212: In the last paragraph, implmentation should be implementation. [Corrected in the 3rd Printing]

p214: There are indenting problems on this page. In the comment box coming off of the LinkTag box, there is a "}" that should be aligned with the word "w" in "while" -- In addition, there are numerous erroneous spaces in the code at the bottom of the page: the code should look more like it does here: Extract Composite. Thanks to Adam Petersen for spotting this. [Corrected in the 3rd Printing]

p223: In the first paragraph, refactoing should be refactoring. [Corrected in the 3rd Printing]

p242: In the middle of the page, please delete all contents of the endTest(...) method on the TextTestResult class. All 4 lines of that method should not be there. Thanks to Naoki Koguro for seeing that. [Corrected in the 3rd Printing]

p249: The code in step 4 has a few errors. The first bit of code should read like so:

ElementAdapter childNode = new ElementAdapter(�);
current.getElement().appendChild(childNode.getElement()); // invocation
And the last chunk of code should read like so:
private void appendChild(
   ElementAdapter parent, ElementAdapter childNode) { 
   parent.getElement().appendChild(childNode.getElement()); 
}

[Corrected in the 3rd Printing]

p269 In the "before" sketch, there should be a dotted line connecting the "client" box with the comment box that contains the words "List nonWhiteProductsBelowNineDollars..." [Corrected in the 3rd Printing]

p271: In the middle of the page, the text should read both model search expressions instead of models. [Corrected in 2nd Printing]

p280: At the bottom of the page, the AndSpec contains two fields of type "ProductSpecification" -- they should actually be of type "Spec" (a shortened version of the name that I switched to). Thanks to Alexander van Vark for spotting this error. [Awaiting correction in 4th printing]

p286: Midway down the page, in the box labeled "SystemPermission" there is a method getState(): SystemPermission -- that should read getState(): PermissionState (in other words, replace SystemPermission with PermissionState). Thanks to Alexander van Vark for spotting this error. [Corrected in the 3rd Printing]

p301 In the after sketch, there is a small comment box with the words "return true" -- that box should have a dotted line coming off of it that connects to the method "mouseMove(...): boolean." See Introduce Null Object to see how it should look. [Corrected in the 3rd Printing]

p328: In the middle of the page, add the word "void" before the methods, accept(...) and visitStringNode(...) so that it looks like this:

class StringNode...
    void accept(Visitor visitor) {
       visitor.visitStringNode(this);
    }

class Visitor {
    void visitStringNode(StringNode stringNode)...
}

[Corrected in the 3rd Printing]

p336: The curly brace below the crossed out (and bolded) line tag.accept(this) should be aligned with the "p" in private, just like the methods below it. [Corrected in 2nd Printing]

p348: In the middle of this page, there is code that says

public class StringNode...
    ...
    return new DecodingNode(
       new StringNode(textBuffer, textBegin, textEnd)
    );
Since a DecodingNode's constructor still has four parameters in this step, the source code should contain another "..." and read like so:
public class StringNode...
    ...
    return new DecodingNode(...,
       new StringNode(textBuffer, textBegin, textEnd)
    );
  

[Corrected in the 3rd Printing]

p348: The last chunk of code on the page contains a blank line above the line "delegate = newDelegate" -- that blank line isn't needed. [Corrected in 2nd Printing]

p356. Joshua Bloch's work is mentioned three times in the text of the book, but shows up only once in the book's index. [Corrected in 2nd Printing]

  Industrial Logic, Inc.

 
Useful Links
· Refactoring to Patterns Catalog
· Martin Fowler's
Refactoring.com
· A Learning Guide
to Design Patterns

3rd Printing

The following entries were added in June, 2006.

XX In the section just above "Who Should Read This Book" please add the following sentence to the last paragraph: For the latest information about this book, please go to its home on the web at https://industriallogic.com/xp/refactoring/

p13: Near top of page, it says "public void Date november(" and should say "public Date november("

Thanks to Patrick Tschorn.

p23: Replace "i" with "e" for Jason Tiscioni. That is, his last name should read Tiscione.

Thanks to Jason himself for this.

p48: In the comment box near top of page, there is code that says "String textBuffer = delegate.toPlainTextString()" That line of code needs to end with a semicolon.

Thanks to Naoki Koguro, Japanese translator of this book.

p66: On the bottom left corner of the page, #Loan should instead say ~Loan to reflect that the Loan's constructor has Java's package-protection access.

Thanks to Patrice Chalin

p68: The sketch has two places where it says (in bold) setStringNodeDecoding(true). This should be changed to setDecodeStringNodes(true) in both places.

Thanks to Naoki Koguro, Japanese translator of this book.

p70: At the top of the page, the word NodeFactory must be in italics.

Thanks to Naoki Koguro, Japanese translator of this book.

p74: At top of the page, in the box called Parser, the word setStringNodeDecoding should be setNodeDecoding. In addition, the word shouldDecodeStringNodes should be shouldDecodeNodes.

Thanks to Naoki Koguro, Japanese translator of this book.

p87: On the bottom right corner of page, it says "return new SortedSet(s)" and should say "return new UnmodifiableSortedSet(s)"

Thanks to Debbie Utley for pointing out this error.

p129: The code in both of call-out boxes begins with the word capital(). It should actually include the word double and be double capital()

Thanks to Naoki Koguro, Japanese translator of this book.

p151: In the middle of the page, the "&rt;" should actually have a "g" instead of an "r".

Thanks to Naoki Koguro, Japanese translator of this book.

p174: At the very top of the page, setPermission should be replaced with setState.

Thanks to Eugene Droi for this.

p175: In the middle of the page, it says

public void claimedBy(SystemAdmin admin) {
  state.claimedBy(admin, this);
}

It should use the word "permissionState" and say

public void claimedBy(SystemAdmin admin) {
  permissionState.claimedBy(admin, this);
}

Thanks to Tim Peng.

p187: In the middle of the page, two crossed-out statements xml.append(" currency='"); and xml.append("price"); are on the same line, but should be on their own lines.

Thanks to Naoki Koguro, Japanese translator of this book.

p189: The class diagram has incorrect attributes. So we need to change

+------------------+
|      TagNode     |
+------------------+
|-attributes:String|
|-tagName:String   |
|-children:List    |
+------------------+
| ...              |
+------------------+

to the following:

+------------------------+
|          TagNode       |
+------------------------+
|-attributes:StringBuffer|
|-name:String            |
|-children:List          |
|-value:String           |
+------------------------+
| ...                    |
+------------------------+

Thanks to Naoki Koguro, Japanese translator of this book.

p196: In the middle of the page, the word void should change to HandlerResponse. So the following

private void getNewWorkshopResponse(Map parameters)
should change to
private HandlerResponse getNewWorkshopResponse(Map parameters) 

Thanks to Jason Southern.

p196: Just before item 2, where it says (in bold) executeActionAndGetResponse it should begin with the word "return" and say return executeActionAndGetResponse.

Thanks to Naoki Koguro, Japanese translator of this book.

p200: In the middle of the page, the Handler class does not show an "execute" method. It must show one (in bold), which would make the code look like so:

public abstract class Handler {
  protected CatalogApp catalogApp;

  public Handler(CatalogApp catalogApp) {
    this.catalogApp = catalogApp;
  }

  public abstract HandlerResponse execute(Map parameters) throws  Exception;
} 

Thanks to Naoki Koguro, Japanese translator of this book.

p257: The code in the comment box on the right-hand side of the class diagram uses the variable named "current", but it should be "currentNode"

Thanks to Naoki Koguro, Japanese translator of this book.

p270: At the bottom of the page, the text that says

public List belowPriceAvoidingAColor(float price)

should include "Color color" and be changed to:

public List belowPriceAvoidingAColor(float price, Color color)

Thanks to Naoki Koguro, Japanese translator of this book.

p279: At the top of the page, the text "boolean isSatisfiedBy(" should include the word "public" and say "public boolean isSatisfiedBy(" In addition, a few lines down, the text "public abstract boolean isSatisfiedBy(Product product);" does not need to include the word "abstract."

Thanks to Naoki Koguro, Japanese translator of this book.

p313: In the middle of the page, the code comment box that says:

writeOpenTagTo(result);
writeValueTo(result);
writeChildrenTo(result);
writeEndTagTo(result); 

should be re-ordered to say

writeOpenTagTo(result);
writeChildrenTo(result);
writeValueTo(result);
writeEndTagTo(result); 

Thanks to some sharp student at Google for noticing this.

p316: At the end of step 1, it says "The compiler is happy with this change." It would be better to say "After changing the + calls to append, the compiler is happy with this change."

Thanks to Naoki Koguro, Japanese translator of this book.

p316: Near the bottom of the page, the code for "writeOpenTagTo" must include a line that says result.append(" "). It should be added in the middle of the method, like so:

private void writeOpenTagTo(StringBuffer result) {
  result.append("<");
  result.append(name);
  result.append(" ");   
  result.append(attributes.toString());
  result.append(">");
}

Thanks to Naoki Koguro, Japanese translator of this book.

p318: At the top of the page the code that says:

private String appendContentsTo(StringBuffer result) {
  writeOpenTagTo(result);
  writeChildrenTo(result);
  ...
  return result.toString();
}

should be changed to the following fragment:

private void appendContentsTo(StringBuffer result) {
  writeOpenTagTo(result);
  writeChildrenTo(result);
  ...
} 

p335: In the middle of the page, both occurrences of the word visitLink should be changed to visitLinkTag

Thanks to Naoki Koguro, Japanese translator of this book.

p336: In step 4 (near top of page), it says "move the accept() method for Tag, EndTag, and Link to those classes." The word Link is incorrect and should say LinkTag.

Thanks to Naoki Koguro, Japanese translator of this book.

p337: In the middle of the page, in step 8, there is no need for the word "abstract" on all 4 of the lines that contain it. All 4 occurrences should be removed.

Thanks to Naoki Koguro, Japanese translator of this book.

p346: In two places on this page, it says

public DecodingNode(
  textBuffer: StringBuffer,
  textBegin: int,
  textEnd: int) {

Both occurrences should be changed to the Java style (not the UML style) and look like so:

public DecodingNode(
  StringBuffer textBuffer,
  int textBegin,
  int textEnd) {

Thanks to Naoki Koguro, Japanese translator of this book.

FacebookFacebook  TwitterTwitter  linked inLinkedIn