Re:Prefer duplication over the wrong abstraction
by weberc2 on Saturday July 09, 2016 @01:17PM
(#12062309)
You don't have to choose. If you have a function* with excessive arguments, it has too many responsibilities. Identify the responsibilities and make a function for each. Then replace the call sites of the original function with only the new functions that are appropriate for that use case. If you find that the same N new functions are repeatedly called in the same places, you can pull those out into a new function as well. It's all very simple, though learning to decompose responsibilities correctly takes practice.
* For sanity's sake, I'm just going to say "function" in place of "abstraction".
* For sanity's sake, I'm just going to say "function" in place of "abstraction".