6.7 Remove Assigments to Parameters(移除对参数的赋值)

概括
代码对一个参数进行赋值。
以一个临时变量取代该参数的位置。
      例子
int discount(int inputVal, int quantity, int yearTodate){
    if(inputVal > 50)
        inputVal = -2;
}

重构后
int discount(int inputVal, int quantity, int yearTodate){
    int result = inputVal;
    if(inputVal > 50)
        result = -2;
}

动机
          对参数赋值降低了代码的清晰度。
做法
.
实践
.




posted @ 2013-11-27 14:44  tanhaiyuan  阅读(189)  评论(0编辑  收藏  举报