Chapter 1. Why I Wrote This Book
Over-Engineering
The Patterns Panacea
Under-Engineering
Test-Driven Development and Continuous Refactoring
Refactoring and Patterns
Evolutionary Design
Chapter 2. Refactoring
What Is Refactoring?
What Motivates Us to Refactor?
Many Eyes
Human-Readable Code
Keeping It Clean
Small Steps
Design Debt
Evolving a New Architecture
Composite and Test-Driven Refactorings
The Benefits of Composite Refactorings
Refactoring Tools
Chapter 3. Patterns
What Is a Pattern?
Patterns Happy
There Are Many Ways to Implement a Pattern
Refactoring to, towards, and away from Patterns
Table 3.1.
Do Patterns Make Code More Complex?
Pattern Knowledge
Up-Front Design with Patterns
Chapter 4. Code Smells
Table 4.1.
Duplicated Code
Long Method
Conditional Complexity
Primitive Obsession
Indecent Exposure
Solution Sprawl
Alternative Classes with Different Interfaces
Lazy Class
Large Class
Switch Statements
Combinatorial Explosion
Oddball Solution
Chapter 5. A Catalog of Refactorings to Patterns
Format of the Refactorings
Benefits and Liabilities
Projects Referenced in This Catalog
XML Builders
HTML Parser
Loan Risk Calculator
A Starting Point
A Study Sequence
Table 5.1.
Chapter 6. Creation
Replace Constructors with Creation Methods
Motivation
Creation Methods and Factory Methods
Benefits and Liabilities
Mechanics
Example
Variations
Parameterized Creation Methods
Extract Factory
Move Creation Knowledge to Factory
Motivation
What Is a Factory?
Benefits and Liabilities
Mechanics
Example
Encapsulate Classes with Factory
Motivation
Benefits and Liabilities
Mechanics
Example
Variations
Encapsulating Inner Classes
Introduce Polymorphic Creation with Factory Method
Motivation
Benefits and Liabilities
Mechanics
Example
Encapsulate Composite with Builder
Benefits and Liabilities
Mechanics
Example
Improving a Builder
Variations
A Schema-Based Builder
Inline Singleton
Motivation
Ward Cunningham on Singletons
Kent Beck on Singletons
Benefits and Liabilities
Mechanics
Example
Chapter 7. Simplification
Compose Method
Motivation
Benefits and Liabilities
Mechanics
Example
Replace Conditional Logic with Strategy
Motivation
Benefits and Liabilities
Mechanics
Example
Move Embellishment to Decorator
Motivation
Decorator versus Strategy
Benefits and Liabilities
Mechanics
Example
Replace State-Altering Conditionals with State
Motivation
Benefits and Liabilities
Mechanics
Example
Replace Implicit Tree with Composite
Motivation
Benefits and Liabilities
Mechanics
Example
Replace Conditional Dispatcher with Command
Motivation
Benefits and Liabilities
Mechanics
Example
Chapter 8. Generalization
Form Template Method
Motivation
Benefits and Liabilities
Mechanics
Example
Extract Composite
Motivation
Benefits and Liabilities
Mechanics
Example
Replace One/Many Distinctions with Composite
Motivation
Benefits and Liabilities
Mechanics
Example
Replace Hard-Coded Notifications with Observer
Motivation
Benefits and Liabilities
Mechanics
Example
Unify Interfaces with Adapter
Motivation
Benefits and Liabilities
Mechanics
Example
Extract Adapter
Motivation
Adapter and Facade
Benefits and Liabilities
Mechanics
Example
Variations
Adapting with Anonymous Inner Classes
Replace Implicit Language with Interpreter
Motivation
Benefits and Liabilities
Mechanics
Example
Chapter 9. Protection
Replace Type Code with Class
Motivation
Benefits and Liabilities
Mechanics
Example
Limit Instantiation with Singleton
Motivation
Benefits and Liabilities
Mechanics
Example
Introduce Null Object
Motivation
Benefits and Liabilities
Mechanics
Example
Background for the Example: Mouse Events in Java 1.0
Chapter 10. Accumulation
Move Accumulation to Collecting Parameter
Motivation
Benefits and Liabilities
Mechanics
Example
Move Accumulation to Visitor
Motivation
Benefits and Liabilities
Mechanics
External Accumulation Method
Internal Accumulation Method
Visitor Replacement
Example
Chapter 11. Utilities
Chain Constructors
Motivation
Mechanics
Example
Unify Interfaces
Motivation
Mechanics
Example
Extract Parameter
Motivation
Mechanics
Example
Afterword
References
Inside Front Cover
List of Refactorings
Refactoring Directions
Inside Back Cover
Code Smells
A Study Sequence