3 ms·
Only experience teaches you where to apply DRY and where not to. Sometimes just because something looks the same or is similar does not mean it’s the same. App
by philliphaydon 4y ago
Only experience teaches you where to apply DRY and where not to.
Sometimes just because something looks the same or is similar does not mean it’s the same. Applying DRY just because it looks the same can have the unwanted consequence of changing in 1 place changing in another too when that’s not the desired affect. Then you add another parameter and conditional logic just because you don’t want 2 similar looking things.
- chrismarlow9 4y agoOut of all the comments on this post, this is the one I agree with the most. I have been bitten by "not enough DRY" as well as "too much DRY". I think experience as well as the maturity of the code are most relevant when deciding things like this. If you do this too early you will back yourself into a corner or eventually end up with a "god function" (usually the outcome of what OP mentions about conditional logic and more params). If you wait too late you will inevitably have a giant codebase with lots of duplicates everywhere. In my experience it's easier to clean up duplicated code than it is to break apart a "master function" that nobody has touched in 3 years out of fear.