Replace Parameter with Explicit Methods
Create a separate method for each value of the parameter.
void setValue (String name, int value) {
if (name.equals("height")) {
_height = value;
return;
}
if (name.equals("width")) {
_width = value;
return;
}
Assert.shouldNeverReachHere();
}
![](http://www.refactoring.com/catalog/arrow.gif)
void setHeight(int arg) {
_height = arg;
}
void setWidth (int arg) {
_width = arg;
}
For more information see page 285 of Refactoring
***** 아름다운프로님에 의해서 게시물 복사 + 카테고리변경되었습니다 (2003-12-18 17:27)