4 ms·
I love the thinking and agree with this as much as can be agreed with something general and lacking specific examples or specific situations. It's a nice remind
by dahart 10y ago
I love the thinking and agree with this as much as can be agreed with something general and lacking specific examples or specific situations. It's a nice reminder that there are other options besides modifying a base class to fit only one case's requirements.
I'd call it forking instead of duplication to emphasize that the paths are different, not equal.
When this problem does come up, it's not usually trivial. Often the abstraction doesn't break at the same time the second use is introduced, it breaks much later after the second use is built, making it more difficult to fix.
The much more common problem I've experienced in industry is people making an abstraction with only one use case, anticipating before even having a second use case. It's much easier to discuss and fix if everything you're facing is concrete, and anticipating uses without having them at hand nearly always results in a broken abstraction.
I'd love to see more about how to determine the abstraction is wrong.
> If you find yourself passing parameters and adding conditional paths through shared code, the abstraction is incorrect.
This seems too simplistic. The right answer for this description is often inheritance. What are better ways to identify a broken abstraction?