Decompose Conditional

Removes smells
Symptom

Multi-clause conditional expressions whose domain meaning isn't readable from the syntax; the agent must parse the expression every time it encounters it.

Goal

Conditions read as named domain decisions; the agent reasons about isSummer(date) instead of re-deriving the month range.

Before the refactoring

if (date < SUMMER_START || date > SUMMER_END) {
charge = qty * winterRate + winterFee;
} else {
charge = qty * summerRate;
}

After the refactoring

charge = isSummer(date)
? summerCharge(qty)
: winterCharge(qty);
Example source: Illustrative example written for this site, not a quotation from any source.
Pressure

The agent re-parses the expression at every reference; debugging the condition's value requires the agent to mentally evaluate the full chain.

Tradeoff

Extracted names that aren't crisper than the original condition add a layer of indirection — the agent now follows a name to find the same expression.

Relief

Each condition and branch lives at one named function the agent reads against the function's name instead of recovering the predicate's domain meaning from its boolean expression.

Trap

Extracting names that don't sharpen the condition — `isMonthBetweenFiveAndEight` instead of `isSummer` — adds indirection without revealing intent.