02
Duplicated Code
Symptom
The same code structure appears in two or more places — same shape with cosmetic variations, or copy-paste-modify patterns that drift over time.
Goal
One canonical home per behavior, with parameters for the variations.
Smellier version
function totalUSD(items) {
return items.reduce((s, i) => s + i.price * i.qty, 0);
}
function totalEUR(items) {
return items.reduce((s, i) => s + i.price * i.qty, 0);
}Fresher versionfunction lineTotal(items) {
return items.reduce((s, i) => s + i.price * i.qty, 0);
}Savings
A bug fix or enhancement lands once, not in every clone — and the unifying name reveals shared intent.
Note
Bugs need to be fixed in every copy; behavior diverges as copies age, multiplying maintenance cost.