Tables of Contents for Refactoring
Who Should Read This Book?
xviii
Building on the Foundations Laid by Others
xix
Refactoring, a First Example
1
52
The First Step in Refactoring
7
1
Decomposing and Redistributing the Statement Method
8
26
Replacing the Conditional Logic on Price Code with Polymorphism
34
18
Principles in Refactoring
53
22
Why Should You Refactor?
55
2
When Should You Refactor?
57
3
What Do I Tell My Manager?
60
2
Problems with Refactoring
62
4
Refactoring and Design
66
3
Refactoring and Performance
69
2
Where Did Refactoring Come From?
71
4
Kent Beck
Martin Fowler
Duplicated Code
76
1
Parallel Inheritance Hierarchies
83
1
Speculative Generality
83
1
Inappropriate Intimacy
85
1
Alternative Classes with Different Interfaces
85
1
Incomplete Library Class
86
1
The Value of Self-testing Code
89
2
The JUnit Testing Framework
91
6
Toward a Catalog of Refactorings
103
6
Format of the Refactorings
103
2
How Mature Are These Refactorings?
106
3
Replace Temp with Query
120
4
Introduce Explaining Variable
124
4
Split Temporary Variable
128
3
Remove Assignments to Parameters
131
4
Replace Method with Method Object
135
4
Moving Features Between Objects
141
28
Introduce Foreign Method
162
2
Introduce Local Extension
164
5
Self Encapsulate Field
171
4
Replace Data Value with Object
175
4
Change Value to Reference
179
4
Change Reference to Value
183
3
Replace Array with Object
186
3
Duplicate Observed Data
189
8
Change Unidirectional Association to Bidirectional
197
3
Change Bidirectional Association to Unidirectional
200
4
Replace Magic Number with Symbolic Constant
204
2
Encapsulate Collection
208
9
Replace Record with Data Class
217
1
Replace Type Code with Class
218
5
Replace Type Code with Subclasses
223
4
Replace Type Code with State/Strategy
227
5
Replace Subclass with Fields
232
5
Simplifying Conditional Expressions
237
34
Decompose Conditional
238
2
Consolidate Conditional Expression
240
3
Consolidate Duplicate Conditional Fragments
243
2
Replace Nested Conditional with Guard Clauses
250
5
Replace Conditional with Polymorphism
255
5
Introduce Null Object
260
7
Making Method Calls Simpler
271
48
Separate Query from Modifier
279
4
Replace Parameter with Explicit Methods
285
3
Preserve Whole Object
288
4
Replace Parameter with Method
292
3
Introduce Parameter Object
295
5
Remove Setting Method
300
3
Replace Constructor with Factory Method
304
4
Replace Error Code with Exception
310
5
Replace Exception with Test
315
4
Dealing with Generalization
319
40
Pull Up Constructor Body
325
3
Replace Inheritance with Delegation
352
3
Replace Delegation with Inheritance
355
4
Kent Beck
Martin Fowler
Tease Apart Inheritance
362
6
Convert Procedural Design to Objects
368
2
Separate Domain from Presentation
370
5
Refactoring, Reuse, and Reality
379
22
William Opdyke
A Reality Check
380
1
Why Are Developers Reluctant to Refactor Their Programs?
381
13
A Reality Check (Revisited)
394
1
Resources and References for Refactoring
394
1
Implications Regarding Software Reuse and Technology Transfer
395
2
Don Roberts
John Brant
Refactoring with a Tool
401
2
Technical Criteria for a Refactoring Tool
403
2
Practical Criteria for a Refactoring Tool
405
2
Putting It All Together
409
4