zoukankan      html  css  js  c++  java
  • 代码重构之内联临时变量

    意图

    - 有一个临时变量,只被一个简单表达式赋值一次,而它妨碍了其他重构手法

    示例

    /**
     * 内联临时变量之前
     * Created by luo on 2017/4/19.
     */
    public class InlineTempBefore {
        Order anOrder = new Order();
    
        public boolean test() {
            double basePrice = anOrder.basePrice();
            return basePrice > 10;
        }
    }
    
    /**
     * 内联临时变量之后
     * Created by luo on 2017/4/19.
     */
    public class InlineTempAfter {
        Order anOrder = new Order();
        private double basePrice;
    
        public boolean test() {
            return basePrice > anOrder.basePrice();
        }
    
    }
  • 相关阅读:
    C++ reference
    C++ const 限定符
    POJ 1222 EXTENDED LIGHTS OUT(高斯消元)
    poj 2185
    poj 2406
    poj 2752
    hdu 6171
    hdu 6127
    uva 3708
    hdu 6092
  • 原文地址:https://www.cnblogs.com/luoxiaolei/p/6759109.html
Copyright © 2011-2022 走看看