4 ms·
How is it harder to copy/paste the helper method and modify as needed, vs tracking down and unifying multiple instances of the same code written slightly differ
by hackinthebochs 6y ago
How is it harder to copy/paste the helper method and modify as needed, vs tracking down and unifying multiple instances of the same code written slightly differently?
- amelius 6y agoBecause the multiple instances are concrete while the unified code is abstract. In general it is more difficult to read abstract code than concrete code. Also code written using the wrong abstaction can get hairy very quickly (lots of "if" statements for various cases).
- fiddlerwoaroof 6y agoIn Java, when I hit a bad abstraction, I hit the inline shortcut (command-alt-n) and then evaluate the resulting code with git diff. Other languages may be more manual, but, at worst, you just use ripgrep or similar to find all the relevant use sites and then manually expand the abstraction: this is only really a problem it the function is used hundreds of time: but, in that case, you can always duplicate the abstraction and rename.