> But say I want to change the system so that, in some cases, it calls Baz instead of Bar - but I don't want to rip the system apart and change every call site. With OOP, I just make a class Quux inheriting from Foo, have it override Bar(stuffs) to do Baz code, and shove a Quux object into the system. Done. Dynamic linking ensure that my new implementation gets called for Quux objects.
Functional programming does this with pattern matching, it is just as easy and avoids the dangers of sub-classing.
There’s another side, which is that from a source code management perspective, modern pattern matching forces you to group implementation by operation (to get all the benefits), modern OO let’s you group by “class”.
There’s no right or wrong answer here. For GUIs, it appears grouping by class is more effective. But many other times, it’s not.
Functional programming does this with pattern matching, it is just as easy and avoids the dangers of sub-classing.