Re:I don’t buy “duplication is cheaper than the wrong abstra...
by oxfordmale on Tuesday August 29, 2023 @01:57PM
(#37311499)
Splitting the abstraction is never cheap and quick, mostly because of politics. With duplicated code you often can assign a single responsible owner to each duplication.
However, once abstracted, the code may suddenly be used by a number of different teams. You will need to get this work on their roadmap, increasing the friction to get this done. In many companies, this will also end up in endless discussions about the new approach.
Re:I don’t buy “duplication is cheaper than the wrong abstra...
by esafak on Tuesday August 29, 2023 @02:31PM
(#37311921)
This is a good point. Following Conway's Law, a team may choose to duplicate code or do thing theoretically sub-optimally simply to avoid having to deal with other teams.
Re:I don’t buy “duplication is cheaper than the wrong abstra...
by yellowapple on Tuesday August 29, 2023 @02:46PM
(#37312114)
Solution there would be to make the abstraction "opt-in", such that a team can elect to duplicate or abstract as desired. Also helps if the "main" abstraction is itself composed from smaller abstractions, from which downstream teams could then pick-and-choose rather than having to either fully abstract or fully duplicate.
Re:I don’t buy “duplication is cheaper than the wrong abstra...
by jrumbut on Tuesday August 29, 2023 @02:32PM
(#37311933)
I think the key here is the oft repeated but often poorly understood maxim to favor composition ("has a") over inheritance ("is a").
If you have a mixin (or other means of composition) that you use in several places and one diverges, it's easy to remove it. If you use inheritance, it's going to be more painful.
A language that offers OOP via prototypes instead of classes like JS can (sometimes) give you the best of both worlds, but it will confuse a lot of devs who aren't familiar with that kind of OO design.
Then you split that abstraction again. It's very cheap and very quick.
Many people talk about the issue like it was an absolute in the code, but that's wrong approach. If you end up writing 4 functions that are the same, by all means, merge it into one.
If then you need to add a parameter only this code path uses and rest doesn't care about, by all means split it back. Moving blocks of code around is cheap.