Extract Method
How
- Pick a name for the new method.
- Move extracted code into the new method.
- Call the new method from the point of extraction.
Uses
- Remove Long Method⭐
- Sets the stage for moving behavior via Move Method⭐.
- Resolves obscurity by introducing intention-revealing names.
- Allows removal of Duplicated Code by moving the common code into the extracted method.
- Reveals complexity, making it easier to follow the Single Responsibility Principle.
- Makes behavior easier to reuse, making it easier to avoid duplication.
Replace Temp with Query
One simple way to extract methods is by replacing local variables.