
This is an attempt to re-classify Fowler's refactorings with respect to structure, identifying the structural element to which each refactoring primarily applies - these elements, in Java, being the method, class and package - and showing whether the refactoring creates (C) or destroys (D) elements, or merely transforms (T) element relationships without creating or destroying elements. These tables are discussed in the post here.
| Refactoring | Method | Class | Package |
| Extract Method | C | ||
| Inline Method | D | ||
| Inline Temp | |||
| Replace Temp with Query | C | ||
| Introduce Explaining Variable | |||
| Split Temporary Variable | |||
|
Remove Assignments to Parameters |
|||
|
Replace Method with Method Object |
C | ||
| Substitute Algorithm |
Table 1: Composing methods refactorings.
| Refactoring | Method | Class | Package |
| Move Method | T | ||
| Move Field | |||
| Extract Class | C | ||
| Inline Class | D | ||
| Hide Delegate | T | ||
| Remove Middle Man | T | ||
| Introduce Foreign Method | C | ||
| Introduce Local Extension | C |
Table 2: Moving features between objects.
| Refactoring | Method | Class | Package |
| Self Encapsulate Field | C | ||
|
Replace Data Value with Object |
C | ||
| Change Value to Reference | |||
| Change Reference to Value | |||
| Replace Array with Object | C | ||
| Duplicate Observed Data | C | ||
|
Change Unidirectional Association to Bidirectional |
T | ||
|
Change Bidirectional Association to Unidirectional |
T | ||
|
Replace Magic Number with Symbolic Constant |
|||
| Pretend to be Dead | |||
| Encapsulate Field | C | ||
| Encapsulate Collection | C | ||
|
Replace Record with Data Class |
C | ||
|
Replace Type Code with Class |
C | ||
|
Replace Type Code with Subclasses |
C | ||
|
Replace Type Code with State Strategy |
C | ||
| Replace Subclass with Fields | D |
Table 3: Organizing data.
| Refactoring | Method | Class | Package |
| Decompose Conditional | C | ||
| Consolidate Conditional | C | ||
|
Consoidate Duplicate Conditional Fragments |
|||
| Remove Control Flag | |||
|
Replace Nested Conditional with Guard Clauses |
|||
|
Replace Conditional with Polymorphism |
C | ||
| Introduce Null Object | C | ||
| Introduce Assertion |
Table 4: Simplifying conditional expressions.
| Refactoring | Method | Class | Package |
| Rename Method | |||
| Add Parameter | |||
| Remove Parameter | |||
|
Separate Query from Modifier |
C | ||
| Parameterize Method | D | ||
|
Replace Parameter with Explicit Methods |
C | ||
| Preserve Whole Object | |||
| Replace Parameter with Method | |||
| Introduce Parameter Object | C | ||
| Remove Setting Method | D | ||
| Hide Method | |||
|
Replace Constructor with Factory Method |
C | ||
| Encapsulate Downcast | |||
|
Replace Error Code with Exception |
C | ||
| Replace Exception with Test |
Table 5: Making method calls simpler.
| Refactoring | Method | Class | Package |
| Pull up field | |||
| Pull Up Method | T | ||
| Pull Up Constructor | T | ||
| Push Down Method | T | ||
| Push Down Field | |||
| Extract Subclass | C | ||
| Extract Superclass | C | ||
| Extract Interface | T | ||
| Collapse Hierarchy | D | ||
| Form Template Method | T | ||
|
Replace Inheritance with Delegation |
T | ||
|
Replace Delegation with Inheritance |
T |
Table 6: Dealing with generalization.