public class Movie{
public static final int CHILDRENS =2 ;
public static final int REGULAR = 0 ;
public static final int NEW_RELEASE = 1;
private String _title;
private int _priceCode;
public Movie(String title, int priceCode){
_title= title;
_priceCode = priceCode;
}
public int getPriceCode(){
return _priceCode;
}
public void setPriceCode(int arg){
_priceCode = arg;
}
}
为即将修改的代码建立一组可靠的测试环境。进行重构的时候,我们需要依赖测试。好的测试是重构的根本。
-
第一步骤是找出代码的逻辑泥团并运用Extract Method。
重构技术就是以微小的步伐修改程序。如果你犯下错误,很容易便可发现他。###
重构的节奏:测试、小修改、测试、小修改、测试,小修改....