Classes / instances in Ontology
Asked Answered
E

3

8

I'm trying to comprehend ontology basics. Here's an example:

  • car (class)
  • 2009 VW CC (sub-class or instance?)
  • My neighbor's 2009 VW CC (instance)

My issue is understanding what is "2009 VW CC" (as a car model). If you're making product model a sub-class in the ontology - all of a sudden your ontology becomes bloated with thousands of subclasses of a "car". That's redundant. At the same time we can't say "2009 VW CC" is an instance, at least it's not material instance of a class.

Does it make sense to distinguish between regular instances and material (distinct physical objects)?

At the other hand, if both are instances (of different nature so to say), then how can instance inherit properties / relations of a non-class?

Ecuador answered 17/4, 2010 at 3:6 Comment(0)
X
7

I hate to say it depends, but it depends.

If you need to model every single car in the world, and have methods that you can call on them (like "change tyre", which is a process that is very different for each model) then yes, you are going to have a lot of bloated classes, because your real world situation is bloated too.

If you just want to have a database of pictures of archetypal cars, and you don't car whether it is a picture of your neighbour's instance or your sister's instance, then you can drop the bottom layer. "2009 VW CC" could well be an instance, even though you can visualise that it is also a class in another model.

Alternatively, maybe you don't need to make it a true subclass at all. A simple reference might be sufficient. For example, an insurance company knows about a large list of car models and years, but the developers don't write one subclass for each. Instead, they have a database of car models, where one row may represent 2009 VW CC. When you insure your car, they create an instance of "Insured Car" with a reference to the "2009 VW CC" instance.

This doesn't strictly follow the "Use inheritance for a 'is-a' relationship", but the operations on all the car types are identical - it is just the parameters (e.g. insurance price per annum) that change, and new car models are recorded in the database, not in the code.

An assumption here is that you can model the differences between the difference models as merely parameters to the same methods on car.

(Aside: When the iPhone started becoming available through phone company web sites, I noticed that it broke their class models - their web-sites seemed to handle dozens of brands and models of phone on one page - presumably using a simple database of phones and their features - and then needed a special page to handle the iPhone models, presumably because new special methods were required on their classes to support some aspects of the iPhone sale. Automated sales desks would say "Press 1 to buy a phone. Press 2 to buy an iPhone.")

Xavierxaviera answered 17/4, 2010 at 3:56 Comment(2)
I don't intend to model every instance of a car (or any product for that matter) but I want to provision a way to do this in my application. For example if a product is released in a limited edition, or is sufficiently unique / customized.Ecuador
Then maybe a hybrid model is appropriate. Standard_Car inherits from Car, and has a a reference to a database of different models it supports. Custom_Car inherits from Car and itself has subclasses for each type of car which is both different enough and important enough to go through the expensive step of modelling in the code. Your neighbour's car may be an instance of Standard_Car or one of the customised subclasses of Car, depending on its novelty.Xavierxaviera
T
1

You have it backwards.

2009 VW CC inherits from the class car. Thus 2009 VW CC needs to know about car, but car doesn't need to know about 2009 VW CC. Though we do occasionally use the term "subclass" in reality, car knows nothing about any of its subclasses.

What's more interesting is if you consider prototypal inheritance (like in javascript), where objects inherit directly from other objects (imagine if your 2009 VW CC inherited the aspects of your neighbor's 2009 VW CC). In reality how this is implemented is that new object have a secret pointer back to the object they inherited from. If you think about this secret pointer you can see how the originating object doesn't become bloated.

Now if you're suggesting that multiple inheritance and long family trees can lead to confusing structures, then I would agree with you.

Trifle answered 17/4, 2010 at 3:33 Comment(5)
I agree with your second paragraph, but I can't see where SODA disagrees with it or gets it backwards. I don't even see where he is suggesting multiple inheritance or long family trees. He seems worried about a WIDE family tree, underneath car.Xavierxaviera
He is thinking that class needs to know subclass. This is backwards. Only subclass needs to know about class.Trifle
Thanks, these are excellent ideas. So it seems like in real life, if we keep our structure manageable, we can say that products (in sense of product models) are all instances, which can have even more concrete instances with even more specific properties?Ecuador
I didn't imply (or even think about a concept) of classes or sub-classes "knowing" anything. It's an interesting way to look at it though.Ecuador
Oddthinking - exactly, my concern is keeping ontology manageable, so what would ordinarily become an instance, is not exactly an instance because there are "real world" instances, but making them sub-classes would eventually translate into an unmanageable ontology.Ecuador
M
0

I really agree with Oddthinking. Plus, if you need car models as classes, "all of a sudden your ontology becomes bloated with thousands of subclasses of a car" actually is not a problem. Why should it be? You just define classes instead of individuals, you might have an 'abstract' ontology, with base classes, and a 'concrete' ontology, with classes that represent the particular situation in real world. This is not OOP, defining thousand classes that are actually somewhat in between between instances and classes is no big deal, at least conceptually, nobody consider this 'bloated' or strange in any other way. Indeed, they do it all the time in my field (life science, where we typically don't care about the proteins P53 in our body, so P53 is a class, even though it's also used to model a record in a relational database).

Except, well, my experience is that tools like Virtuoso seem optimised for the situation of few classes and many instances. In fact, I've observed significant performance improvements when I turned million of classes in Virtuoso into instances. So, well, it's complicated...

Massingill answered 29/3, 2015 at 22:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.