A Minimal Book Example
Preface
1
What is refactoring?
2
Code Smells
2.1
Bloaters
2.1.1
Long Function
2.1.2
Primitive/Atomic Obsession
2.1.3
Data Clumps
2.1.4
Many Parameters
2.2
Change Preventers
2.2.1
Divergent Change
2.2.2
Shotgun Surgery
2.3
Dispensables
2.3.1
Comments
2.3.2
Duplicate Code
2.3.3
Dead Code
2.3.4
Dead Stores
2.3.5
Speculative Generality
2.4
Others
2.4.1
Lazy Element
2.4.2
Loops
2.4.3
Mysterious Name
2.4.4
Repeated Switches
2.5
Smells not covered in this book
3
Refactorings
3.1
Composing Methods
3.1.1
Extract Function
3.1.2
Inline Function
3.1.3
Extract Variable
3.1.4
Inline Temp
3.1.5
Replace Temp with Function
3.1.6
Split Temporary Variable
3.1.7
Remove Assignments to Parameters
3.1.8
Replace Method with Method Object
3.1.9
Substitute Algorithm
3.2
Moving Features between Objects
3.2.1
Move Method
3.2.2
Move Field
3.2.3
Extract Class
3.2.4
Inline Class
3.2.5
Hide Delegate
3.2.6
Remove Middle Man
3.2.7
Introduce Foreign Method
3.2.8
Introduce Local Extension
3.3
Organizing Data
3.3.1
Change Value to Reference
3.3.2
Change Reference to Value
3.3.3
Duplicate Observed Data
3.3.4
Self Encapsulate Field
3.3.5
Replace Data Value with Object
3.3.6
Replace Array with Object
3.3.7
Change Unidirectional Association to Bidirectional
3.3.8
Change Bidirectional Association to Unidirectional
3.3.9
Encapsulate Field
3.3.10
Encapsulate Collection
3.3.11
Replace Magic Number with Symbolic Constant
3.3.12
Replace Type Code with Class
3.3.13
Replace Type Code with Subclasses
3.3.14
Replace Type Code with State/Strategy
3.3.15
Replace Subclass with Fields
3.3.16
Replace Atomic with S3 Class
3.4
Simplifying Conditional Expressions
3.4.1
Consolidate Conditional Expression
3.4.2
Consolidate Duplicate Conditional Fragments
3.4.3
Decompose Conditional
3.4.4
Replace Conditional with Polymorphism
3.4.5
Remove Control Flag
3.4.6
Replace Nested Conditional with Guard Clauses
3.4.7
Introduce Null Object
3.4.8
Introduce Assertion
3.5
Simplifying Method Calls
3.5.1
Add Parameter
3.5.2
Remove Parameter
3.5.3
Rename Method
3.5.4
Separate Query from Modifier
3.5.5
Parameterize Method
3.5.6
Introduce Parameter Object
3.5.7
Preserve Whole Object
3.5.8
Remove Setting Method
3.5.9
Replace Parameter with Explicit Methods
3.5.10
Replace Parameter with Method Call
3.5.11
Replace Parameter with Query
3.5.12
Hide Method
3.5.13
Replace Constructor with Factory Method
3.5.14
Replace Error Code with Exception
3.5.15
Replace Exception with Test
3.6
Dealing with Generalization
3.6.1
Pull Up Field
3.6.2
Pull Up Method
3.6.3
Pull Up Constructor Body
3.6.4
Push Down Field
3.6.5
Push Down Method
3.6.6
Extract Subclass
3.6.7
Extract Superclass
3.6.8
Extract Interface
3.6.9
Collapse Hierarchy
3.6.10
Form Template Method
3.6.11
Replace Inheritance with Delegation
3.6.12
Replace Delegation with Inheritance
3.7
Other
3.7.1
Remove Dead Code
3.7.2
Change Function Declaration
3.7.3
Replace Loop With Apply
3.7.4
Rename Function
3.7.5
Rename Argument
3.7.6
Rename Variable
Published with bookdown
Refactoring in R
Chapter 1
What is refactoring?