08
Introduce Parameter Object
Goal
Related arguments travel together as one well-named value object that the function (and callers) refer to by name.
Before the refactoring
function record(low, high, value) {
// ...
}After the refactoringclass NumberRange { /* low, high */ }
function record(range, value) {
// ...
}Savings
Adding a related field is one type change instead of touching every call site; intent is named.
Note
Premature parameter objects hide which fields are actually needed by which method — wait until the clump appears in 3+ places before extracting.