Smalltalk and Python

Neil Cerutti cerutti at together.net
Fri Dec 15 16:00:29 EST 2000


Alex Martelli posted:
>What classes are 'abstract' (not actually instantiated as
>themselves, but only in terms of their subclasses) or 'concrete'
>(directly instantiable without subclassing) is part of what your
>O-O analysis is determining, and will depend on what exactly
>you're trying to do.  The root of the 'only abstract classes
>ever get subclassed' idea is that there is an inconsistency of
>levels-of-detail in your analysis if it allows subclassing of
>instantiable classes.  If your application-needs (or more
>generally, your domain-modeling needs) are such that you need to
>distinguish between, e.g., different kinds of 'vehicles' (cars
>vs trucks vs planes vs ...), then 'Vehicle' itself, the common
>superclass, cannot be instantiable in a logically consistent way
>-- it would break the idea that your concrete classes partition
>the universe of discourse, if it were.
>
>This is based on the idea of subclassing as asserting IS-A.
>
>As, say, a Plane IS-A Vehicle, it cannot be the case (if your
>concrete classes partition the universe of discourse) that a
>(generic) Vehicle is instantiable; else, you would have
>ambiguity in what concrete class to use to model an actual plane
>-- either a concrete Plane or a concrete generic Vehicle would
>satisfy all expressed constraints.  In practice, object-models
>which allow instantiation of a superclass (such as Vehicle) do
>so by adding a NON-expressed constraint about using the most
>'leaf' class an actual object can possibly be modeled as; but,
>that analysis-constraint is left non-explicitly-expressed in the
>object model... it CANNOT be expressed in it.  Whatever semantic
>constraints we attach to Vehicle will get inherited by Plane, so
>we cannot say *of Vehicle instances* 'and this is not
>specifically a Plane', else, bye-bye IS-A.

Luckily, the objects we model in software are generally simpler
and easier to define than a Vehicle class. In the real world,
things have "family relationships", (Wittgenstein?)--you can't
always make an easy determination about what class a thing
belongs to. In an ocean simulation, you might have a Fish class
and it would be useful for the Dolphin class to inherit, but it
IS-NOT a fish.

Perhaps it makes sense to instantiate a Vehicle if you believe in
Plato's idea of an ideal vehicle. All other vehicles will be
different or imperfect in some way, but the ideal could exist and
be instatiated--by God, er... by the programmer. ;-)

-- 
Neil Cerutti <cerutti at together.net>



More information about the Python-list mailing list