Great post on inheritance from the Sicpers blog, and why — as a concept — it often fails in OO languages such as Java.
This blog post can help you understand why:
- “Cat and Dog extend Animal” is poor use of OO.
- “Square extends Rectangle” is poor use of OO.
From my own experience, I’ve moved to primarily using inheritance in only two ways: Continue reading →
One of the most profound insights I have learnt about OO is that class design — the shaping of classes & types — is best informed by what processing needs to do, rather than the ‘kind’ of entities it goes between.
What we are talking about here is behavior, rather than trying to categorize entities at rest. Program code only acts by being executed; classes & interfaces (types) are a mechanism to despatch that execution to specific methods.
This shows that OO is really about active behavior, rather than any other arbitrary notions of classification.
But shouldn’t inheritance just follow Entity Properties?
At this point, we’ll address a common interjection — what about bean-style entities, and their properties? Surely inheritance should just follow these! Continue reading →
Real software sees entities (Customer, File etc) involved in multiple interactions. Simple OO examples model behavior in entity classes directly, but this becomes tangled as behaviors & interactions increase; and results in broken inheritance structures.
Instead of modelling these all in the entity, a more advanced OO approach considers separating behavior from the entity. We’ll consider key principles in this multi-part series. Continue reading →
Insights into Java coding, OO design & architecture