| |
| |
Foreword | |
| |
| |
| |
Foreword | |
| |
| |
| |
Preface | |
| |
| |
What Is This Book About? | |
| |
| |
What Are the Goals of This Book? | |
| |
| |
Who Should Read This Book? | |
| |
| |
What Background Do You Need? | |
| |
| |
How to Use This Book | |
| |
| |
The History of This Book | |
| |
| |
Standing on the Shoulders of Giants | |
| |
| |
Acknowledgments | |
| |
| |
| |
Why I Wrote This Book | |
| |
| |
Over-Engineering | |
| |
| |
The Patterns Panacea | |
| |
| |
Under-Engineering | |
| |
| |
Test-Driven Development and Continuous Refactoring | |
| |
| |
Refactoring and Patterns | |
| |
| |
Evolutionary Design | |
| |
| |
| |
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 | |
| |
| |
| |
Patterns | |
| |
| |
What Is a Pattern? | |
| |
| |
Patterns Happy | |
| |
| |
There Are Many Ways to Implement a Pattern | |
| |
| |
Refactoring to, towards, and away from Patterns | |
| |
| |
Do Patterns Make Code More Complex? | |
| |
| |
Pattern Knowledge | |
| |
| |
Up-Front Design with Patterns | |
| |
| |
| |
Code Smells | |
| |
| |
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 | |
| |
| |
| |
A Catalog of Refactorings to Patterns | |
| |
| |
Format of the Refactorings | |
| |
| |
Projects Referenced in This Catalog | |
| |
| |
XML Builders | |
| |
| |
HTML Parser | |
| |
| |
Loan Risk Calculator | |
| |
| |
A Starting Point | |
| |
| |
A Study Sequence | |
| |
| |
| |
Creation | |
| |
| |
Replace Constructors with Creation Methods | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
Variations | |
| |
| |
Move Creation Knowledge to Factory | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
Encapsulate Classes with Factory | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
Variations | |
| |
| |
Introduce Polymorphic Creation with Factory Method | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
Encapsulate Composite with Builder | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
Variations | |
| |
| |
Inline Singleton | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
| |
Simplification | |
| |
| |
Compose Method | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
Replace Conditional Logic with Strategy | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
Move Embellishment to Decorator | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
Replace State-Altering Conditionals with State | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
Replace Implicit Tree with Composite | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
Replace Conditional Dispatcher with Command | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
| |
Generalization | |
| |
| |
Form Template Method | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
Extract Composite | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
Replace One/Many Distinctions with Composite | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
Replace Hard-Coded Notifications with Observer | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
Unify Interfaces with Adapter | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
Extract Adapter | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
Variations | |
| |
| |
Replace Implicit Language with Interpreter | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
| |
Protection | |
| |
| |
Replace Type Code with Class | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
Limit Instantiation with Singleton | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
Introduce Null Object | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
| |
Accumulation | |
| |
| |
Move Accumulation to Collecting Parameter | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
Move Accumulation to Visitor | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
| |
Utilities | |
| |
| |
Chain Constructors | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
Unify Interfaces | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
Extract Parameter | |
| |
| |
Motivation | |
| |
| |
Mechanics | |
| |
| |
Example | |
| |
| |
Afterword | |
| |
| |
| |
References | |
| |
| |
Index | |