Partial Application

Replace Parameter With Method

Refactoring Catalog§: Replace Parameter with Method

An object invokes a method, then passes the result as a parameter for a method. The receiver can also invoke this method. Remove the parameter and let the receiver invoke the method.

Before:

int basePrice = _quantity * _itemPrice;
discountLevel = getDiscountLevel();
double finalPrice = discountedPrice (basePrice, discountLevel);
      

int basePrice = _quantity * _itemPrice;
double finalPrice = discountedPrice (basePrice);