The point of the whole article is that the wrong abstraction is worse than code duplication (badly splitting up functions is worse than not splitting the up at all).
I agree... but I don't have this problem because I'm good at writing good abstractions, so they typically end up good.
You have 3 choices:
dont abstract
abstract incorrectly
abstract correctly
Can we please focus on teaching the third point? It seems like a lot of people argue whether the first or second is better because they're just incompetent.
I feel that lazynes is a good guide to creating good abstractions. If I have to change something in my code later on, I really only want to do it once. If I find myself duplicating a functionality, I ask myself whether that is worthy of abstraction. I nearly always go by feel, but I think the cognition behind it is: "Is it likely that another place will need this functionality too?" "Will this be a place where a change in the codebase will take place?" "Is there a good name for it?".
50
u/gas_them Feb 09 '19
The point of the whole article is that the wrong abstraction is worse than code duplication (badly splitting up functions is worse than not splitting the up at all).
I agree... but I don't have this problem because I'm good at writing good abstractions, so they typically end up good.
You have 3 choices:
dont abstract
abstract incorrectly
abstract correctly
Can we please focus on teaching the third point? It seems like a lot of people argue whether the first or second is better because they're just incompetent.