11.2: Refactorings
- Page ID
- 32429
Encapsulate Field
Also Known As: Abstract Instance Variable [Rob99].
Intent There is a public field. Make it private and provide accessors.
Source: Refactoring: Improving the Design of Existing Code [FBB+99].
Referenced from: Eliminate Navigation Code.
Extract Method
Intent You have a code fragment that can be grouped together. Turn the fragment into a method whose name explains the purpose of the method.
Source: Refactoring: Improving the Design of Existing Code [FBB+99].
Referenced from: Refactor to Understand, Visualize Code as Dotplots, Move Behavior Close to Data.
Move Method
Intent A method is, or will be, using or used by more features of another class than the class on which it is defined. Create a new method with a similar body in the class it uses most. Either turn the old method into a simple delegation, or remove it altogether.
Source: Refactoring: Improving the Design of Existing Code [FBB+99].
Referenced from: Refactor to Understand, Move Behavior Close to Data.
Rename Attribute
Intent Rename an instance variable and update all references to it.
Source: Practical Analysis for Refactoring [Rob99].
Referenced from: Refactor to Understand.
Rename Method
Intent The name of a method does not reveal its purpose. Change the name of the method.
Source: Refactoring: Improving the Design of Existing Code [FBB+99].
Referenced from: Refactor to Understand.
Replace Conditional with Polymorphism
Intent You have a conditional that chooses different behavior depending on the type of an object. Move each leg of the conditional to an overriding method in a subclass. Make the original method abstract.
Source: Refactoring: Improving the Design of Existing Code [FBB+99].
Referenced from: Transform Client Type Checks.