3 ms·
In my experience, instances where removing duplication made code worse have usually been because the code is similar in its mechanical behavior but very differe
by harimau777 8y ago
In my experience, instances where removing duplication made code worse have usually been because the code is similar in its mechanical behavior but very different in its purpose. I wonder if a rule of thumb could be to judge duplication more on the purpose or function of the code rather than the mechanics of how it is implemented.
For example, suppose you have two promise based functions with error checking; one of which is doing a fetch and the other is performing a complex calculation. The error checking blocks might be the same since they are mechanically performing the same tasks; however, since the errors they are likely to see are so different a generic version could make the code more difficult to understand.