www.sixfingeredman.net
..................................................
::. .  .   .     .       .          .

HOME
readme
brain
ideas
todo
writing
photos
graphics
projects
quotes
recipes
books
movies
links
old site

object-oriented type system

To: Chris Date

First, I thoroughly enjoy the Database Debunking site; thank you and your fellow contributors for making it publically available. To business: I have a few thoughts in response to your article ``Type Inheritance: Is a Circle an Ellipse?'' found at [http://www.firstsql.com/dbdebunk/cjd8a.htm]. Specifically I hope I can shed some light on what I've observed of OOP and its notions of inheritance. Disclaimer: I have no formal training in this area, and therefore most of what I say has almost certainly been said previously and more clearly. Furthermore, you have yourself made points along very similar lines. Hopefully this will still be of some use.

Type is not analogous to class in OOP. In truth, I'd say that the notion of type is not used at all in OOP.

In OOP, a class is a value and a set of functions. Together, these implicitly define a type: it is the set of all values reachable by that class. By a reachable value I mean one which can be generated by applying one of the functions of the class to the value of the class or to another reachable value.

The functions of a subclass are a superset of the functions of its superclass. That is the definition of inheritance; again, nothing to do with types.

An object is a class and a value reachable by that class. An object is said to be an instance of its class. Note that two objects may have the same value but be of different classes, and furthermore that unlike types, every object has one and only one class.

To apply this concretely to the ellipse and circle problem: the circle type is obviously a subtype of the ellipse type. However, according to the definition above which I believe accurately reflects the conceptual model in the industry, the circle class is actually a superclass of the ellipse class, as you noted. OOP gurus say otherwise only because this is contrary to the intuitive mapping people make between types and classes.

-- Adrian Kubala


adness is rare in individuals, but in groups, parties, nations, and ages it
is the rule.
	-- Friedrich Nietzsche