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.


		int basePrice = _quantity * _itemPrice;

		discountLevel = getDiscountLevel();

		double finalPrice = discountedPrice (basePrice, discountLevel);




		int basePrice = _quantity * _itemPrice;

		double finalPrice = discountedPrice (basePrice);



For more information see page 292 of Refactoring

| Refactoring Home | | Alphabetical List |