Also described on page 142 of MartinFowler
- "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."
-ing, you discover a method that is very tightly bound to another class, but not to its own.
move the method.
area := bounds bottom - bounds top * (bounds right - bounds left).
^self bottom - self top * (self right . self left)
area := bounds area.
You may be able to use this refactoring any time you see two or more messages in a single method going to an object other than self.
What do you do when you'd like to MoveMethod
, but you are not able to change the desired destination class because it is in SomebodyElsesFramework
, or due to restrictive configuration management policies? See ForeignMethod
See also WithBlockCodeSmell
View edit of August 26, 2002
or FindPage with title or text search