重构既有代码.ppt

重构既有代码.ppt

坏味道 public int discount( int price ) { if( price 1000) { price -= 20; …….. } return price; } public int discount( final int price ) { int ret = price; if( price 1000) { ret -= 20; …….. } return ret ; } 传值参数不能用赋值,职责不明确,应用创建临时变量对其操作 坏味道 double temp = 2 * (_height + _width); System.out.println (temp); temp = _height * _width; System.out.println (temp); double perimeter = 2 * (_height + _width); System.out.println (perimeter); double area = _height * _width; System.out.println (area); 职责不明确 ColdRule *newRule = new ColdRule(); newRule-SetOID(oldRule-Ge

文档评论(0)

1亿VIP精品文档

相关文档