31 ms·
Can you expand om what of code duplication you deem reasonable?
by dgan 2y ago
Can you expand om what of code duplication you deem reasonable?
- jumploops 2y agoEarly in a project you see a lot of similar code paths, and so it’s often tempting to take the logic from two or three e.g. API routes and merge the “clean” abstraction into single piece of logic both routes can call. Over-time this “clean” abstraction adopts a bunch of optional parameters based on the upstream API routes, leaving you with an omni-function that is more convoluted, and thus harder to change, than if the API routes weren’t overly optimized from the get-go. As a personal rule, I’ll let myself copy something 3 times before taking a step back and figuring out a “better” way.
- dgan 2y agoA very reasonable approach indeed