Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There is a direct mapping between our natural construction of ontologies (we are pattern-detecting creatures, we naturally see commonalities across the birds) and why object orientation works. Cars are a subset of vehicles in most peoples' minds; and Buttons are a subset of Controls in most UI programmers' minds. And the topologies of these ontologies are similar enough, by design, that you can indeed teach valuable lessons using vehicles and birds.

As to polymorphism, that comes for free from understanding language. Most people will understand a "No vehicles allowed" sign to prohibit cars but not people. What else is that but an understanding of polymorphism in evaluating a predicate?



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.


I 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: