Move Method
Vehicle
milesTraveled:int
fuelConsumed:int
Engine
milesPerGallon():double
belongsTo:Vehicle
Vehicle
milesPerGallon():double
milesTraveled:int
fuelConsumed:int
Delegates to
Engine
milesPerGallon():double
belongsTo:Vehicle
Let’s look at the move method refactoring in detail, to illustrate what Dr. Jones knows about a typical refactoring.
Suppose we decide that the miles per gallon of a vehicle is really a property of a vehicle, and not its engine, to reduce coupling.
We refactor by moving the method to Vehicle, and leaving a skeleton method behind in Engine that delegates to the new location.
What would Dr. Jones need to know to help me plan this refactoring?