Remove Assignments to Parameters

The code assigns to a parameter.

Use a temporary variable instead.

	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;

For more information see page 131 of Refactoring

| Refactoring Home | | Alphabetical List |