对象调用某个函数,并将其结果传递给另一个函数
int basePrice = quantity * itemPrice;
double discountLevel = getDiscountLevel();
double finalPrice = discountPrice(basePrice, discountLevel);
重构:让参数接受者移除该项参数,并直接调用该函数
int basePrice = quantity * itemPrice;
double finalPrice = discountPrice(basePrice);
动机
如果函数可以通过其他途径获得参数值,那么它就不应该通过参数取得该值。过长的参数列会增加程序阅读者的理解难度。