Contents
About This E-Book
EPUB is an open, industry-standard format for e-books. However, support for EPUB and its many features varies across reading devices and applications. Use your device or app settings to customize the presentation to your liking. Settings that you can customize often include font, font size, single or double column, landscape or portrait mode, and figures that you can click or tap to enlarge. For additional information about the settings and features on your reading device or app, visit the device manufacturers Web site.
Many titles include programming code or configuration examples. To optimize the presentation of these elements, view the e-book in single-column, landscape mode and adjust the font size to the smallest setting. In addition to presenting code and configurations in the reflowable text format, we have included images of the code that mimic the presentation found in the print book; therefore, where the reflowable format may compromise the presentation of the code listing, you will see a Click here to view code image link. Click the link to view the print-fidelity code image. To return to the previous page viewed, click the Back button on your device or app.
List of Refactorings
Change Function Declaration ()
Change Reference to Value ()
Change Value to Reference ()
Collapse Hierarchy ()
Combine Functions into Class ()
Combine Functions into Transform ()
Consolidate Conditional Expression ()
Decompose Conditional ()
Encapsulate Collection ()
Encapsulate Record ()
Encapsulate Variable ()
Extract Class ()
Extract Function ()
Extract Superclass ()
Extract Variable ()
Hide Delegate ()
Inline Class ()
Inline Function ()
Inline Variable ()
Introduce Assertion ()
Introduce Parameter Object ()
Introduce Special Case ()
Move Field ()
Move Function ()
Move Statements into Function ()
Move Statements to Callers ()
Parameterize Function ()
Preserve Whole Object ()
Pull Up Constructor Body ()
Pull Up Field ()
Pull Up Method ()
Push Down Field ()
Push Down Method ()
Remove Dead Code ()
Remove Flag Argument ()
Remove Middle Man ()
Remove Setting Method ()
Remove Subclass ()
Rename Field ()
Rename Variable ()
Replace Command with Function ()
Replace Conditional with Polymorphism ()
Replace Constructor with Factory Function ()
Replace Derived Variable with Query ()
Replace Function with Command ()
Replace Inline Code with Function Call ()
Replace Loop with Pipeline ()
Replace Nested Conditional with Guard Clauses ()
Replace Parameter with Query ()
Replace Primitive with Object ()
Replace Query with Parameter ()
Replace Subclass with Delegate ()
Replace Superclass with Delegate ()
Replace Temp with Query ()
Replace Type Code with Subclasses ()
Separate Query from Modifier ()
Slide Statements ()
Split Loop ()
Split Phase ()
Split Variable ()
Substitute Algorithm ()
Smells
Smell | Common Refactorings |
---|
Alternative Classes with Different Interfaces () | Change Function Declaration () |
Comments () | Extract Function () |
Data Class () | Encapsulate Record () |
Data Clumps () | Extract Class () |
Divergent Change () | Split Phase () |
Duplicated Code () | Extract Function () |
Feature Envy () | Move Function () |
Global Data () | Encapsulate Variable () |
Insider Trading () | Move Function () |
Large Class () | Extract Class () |
Lazy Element () | Inline Function () |
Long Function () | Extract Function () |
Long Parameter List () | Replace Parameter with Query () |
Loops () | Replace Loop with Pipeline () |
Message Chains () | Hide Delegate () |
Middle Man () | Remove Middle Man () |
Mutable Data () | Encapsulate Variable () |
Mysterious Name () | Change Function Declaration () |
Primitive Obsession () | Replace Primitive with Object () |
Refused Bequest () | Push Down Method () |
Repeated Switches () | Replace Conditional with Polymorphism () |
Shotgun Surgery () | Move Function () |
Speculative Generality () | Collapse Hierarchy () |
Temporary Field () | Extract Class () |
Refactoring
Improving the Design of Existing Code
Second Edition
Martin Fowler
with contributions by
Kent Beck
Boston Columbus New York San Francisco Amsterdam Cape Town
Dubai London Madrid Milan Munich Paris Montreal Toronto Delhi Mexico City
So Paulo Sydney Hong Kong Seoul Singapore Taipei Tokyo
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals.
The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein.
For information about buying this title in bulk quantities, or for special sales opportunities (which may include electronic versions; custom cover designs; and content particular to your business, training goals, marketing focus, or branding interests), please contact our corporate sales department at or (800) 3823419.