3 ms·
A lot of confusion comes down to some bad use of inheritance. Probably the most important OO concept is the Liskov Substitution Principal, viz that if you speci
by dhosek 4y ago
A lot of confusion comes down to some bad use of inheritance. Probably the most important OO concept is the Liskov Substitution Principal, viz that if you specify a superclass in a certain place, then any subclass should be a valid use there. The strategy pattern (or its hyperpituitary cousin, IoC) takes advantage of this to allow for run-time change of behaviors, e.g., being able to choose through configuration how to serialize a data structure so the same basic logic can output, say, a dataset as a table or a graph. That said, as OO architecture has matured over the last few decades, there has definitely been a tendency to favor composition over inheritance for code flexibility.
I would recommend Head-First Design Patterns as another great book for being able to “get” object-oriented architecture.