Decompose Conditional

You have a complicated conditional (if-then-else) statement.

Extract methods from the condition, then part, and else parts.

		if (date.before (SUMMER_START) || date.after(SUMMER_END))
			charge = quantity * _winterRate + _winterServiceCharge;
		else charge = quantity * _summerRate;

		if (notSummer(date))
			charge = winterCharge(quantity);
		else charge = summerCharge (quantity);

For more information see page 238 of Refactoring

| Refactoring Home | | Alphabetical List |