2 ms·
Object-orientation does not work because cars are a subset of vehicles. Please do not teach anyone that. Object-orientation works because in some programs, ca
by haberman 15y ago
Object-orientation does not work because cars are a subset of vehicles. Please do not teach anyone that.
Object-orientation works because in some programs, cars can be treated as if they were a vehicle, without knowing what kind of vehicle it is. This is the principle of substitutability, and it's the actual reason that inheritance hierarchies work. But in other programs, cars and other vehicles may not have much in common and should not be part of an inheritance hierarchy!
The real-world ontology is not a reason in and of itself to create an inheritance relationship.
- barrkel 15y agoI think you missed my point. The real-world ontology doesn't exist; it's only in our heads. The mechanisms in our heads for these ontologies are what OO uses and why it works for humans. The point is the commonality of mechanism, not the commonality of any specific ontology. And when you're teaching, that's enough for one lesson.