Move Method
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.
![](http://www.refactoring.com/catalog/moveMethod.gif)
For more information see page 142 of Refactoring
Additional Comments
Marian Vittek sent an example for moving a method to a method argument.
class Project {
Person[] participants;
}
class Person {
int id;
boolean participate(Project p) {
for(int i=0; i
}
return(false);
}
}
... if (x.participate(p)) ...
After applying the move you end up with
class Project {
Person[] participants;
boolean participate(Person x) {
for(int i=0; i
}
return(false);
}
}
class Person {
int id;
}
... if (p.participate(x)) ...
He also points out that the part of the Move Method mechanics that reads Determine how to reference the correct target object from the source, should be replaced by Determine how to reference the correct
target object from the source or from arguments of the method which is more general.
***** 아름다운프로님에 의해서 게시물 복사 + 카테고리변경되었습니다 (2003-12-18 17:27)