3 ms·
A younger self used to be very strict about DRY. For a living codebase, nowadays my general rule of thumb is to consciusly duplicate code until it covers 3 di
by 3np 5y ago
A younger self used to be very strict about DRY.
For a living codebase, nowadays my general rule of thumb is to consciusly duplicate code until it covers 3 different cases, and only then refactor (unless the DRY way is as fast and obvious).
It takes more than that to yield spaghetti and a lot of time is saved on premature generalization. Plus the generalization is often way more straightforward once the explicit cases are already implemented.
- BurningFrog 5y agohttps://en.wikipedia.org/wiki/Rule_of_three_(computer_programming) https://en.wikipedia.org/wiki/Rule_of_three_(computer_progra... I follow this too for "style" refactorings.