Remove Flag Argument

Removes smells
Symptom

A function with a boolean (or enum) flag parameter that dispatches to different internal behaviors — `setDimension('height', value)` vs `setDimension('width', value)`.

Goal

Each flag value becomes its own well-named function; callers say what they mean rather than passing booleans.

Before the refactoring

function setDimension(name, value) {
if (name === 'height') { /* ... */ }
else if (name === 'width') { /* ... */ }
}

After the refactoring

function setHeight(value) { /* ... */ }
function setWidth(value) { /* ... */ }
Example source: Illustrative example written for this site, not a quotation from any source.
Pressure

Call sites must remember the flag's meaning; the function's body is a switch the agent reads through to find each branch; new flag values touch one body that handles many concerns.

Tradeoff

Two replacement functions with similar bodies introduce duplication — pair this with Extract Function for shared internals.

Relief

Call sites read fluently; new variations land as new functions instead of new switch cases.

Trap

Splitting flag-dispatched functions whose branches are mostly shared body — produces N functions with N copies of the same body, inverting the original abstraction.