Re:The Wrong Abstraction (2016)
by hackinthebochs on Sunday July 05, 2020 @12:42PM
(#23739972)
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?
[ Parent
| on HN ]
Because 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).
Re:The Wrong Abstraction (2016)
by fiddlerwoaroof on Sunday July 05, 2020 @01:17PM
(#23740243)
In 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.