29
Remove Flag Argument
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 refactoringfunction setHeight(value) { /* ... */ }
function setWidth(value) { /* ... */ }Savings
Call sites read fluently; new variations land as new functions instead of new switch cases.
Note
Two replacement functions with similar bodies introduce duplication — pair this with Extract Function for shared internals.