4 ms·
I heard a good guideline somewhere, that if multiple pieces of code change at the same time for the same reason, it should be combined into one. If the separate
by Maultasche 3y ago
I heard a good guideline somewhere, that if multiple pieces of code change at the same time for the same reason, it should be combined into one. If the separate pieces of code can change at different times for different reasons (they would likely diverge in different directions the future), it's best to keep them separate places to keep it from being a maintenance nightmare.
Excessive DRY as how you described leads to complexity and complexity is bad for code maintainability. Properly applied DRY is supposed to reduce complexity.
- quickthrower2 3y agoThat guideline would make a better tweet than the submission IMO. It is a very good yardstick. Although even if you have to update 2 places together often it might be worth keeping them seperate for various reasons. Such as combining them require major refactor of dependencies.
- jackblemming 3y agoIf combining them would require a major refactor then create a unit test that fails if they diverge or leave a code comment. That gets you the benefits without the tedium.
- _ea1k 3y agoThat sounds like a good rule of thumb to me.