3 ms·
For well known scenarios i use DRY or not DRY right away. But when I don't know how code will evolve i use three times rule. Three use cases are often enought t
by tomaszs 6y ago
For well known scenarios i use DRY or not DRY right away. But when I don't know how code will evolve i use three times rule. Three use cases are often enought to form an understanding of code usage, to apply DRY if needed.
So I just leave the mess for a while and see what will grow.
It is a perfectly good solution if we accept that refactoring is also a thing. And it should be. Code can not be perfect from day one.
These rules are can be applied widely. For example sometimes it is good to repeat code in s React component and leave it that way.
Especially if it is unknown how the design will evolve. So also it is sometimes better to leave some mess that is easier to manage than to slice everything that may make it harder to manage the code further on.
Often chasing DRY and other rules too early leads to trouble. I call it early optimization. Just let the code breath! Give it some time to make it perfect!