← all notes
Principle2 min

DRY — don't repeat yourself

the third copy-paste is a bug factory, not a shortcut.

Copy-pasting the first time is a reasonable shortcut. The second time, you're creating debt. The third time, you have a bug factory — because now a fix has to be applied in three places, and it never is.

Extract it once, name it well, and stop maintaining the same code in five places. The rule isn't about avoiding repetition for its own sake — it's about having one source of truth for a behavior.

Your future self will thank you — probably at 11pm, in a bugfix, wondering why the fix in module A didn't reach module B.bug factory

the point is simple — the details are not.
further reading3 references