Re: Templated containers of inherited objects
On Feb 20, 1:40 am, Jerry Coffin <jcof...@taeus.com> wrote:
In article <1171874692.373367.62...@s48g2000cws.googlegroups.com>,
kirit.saelensmi...@gmail.com says...
[ ... ]
OO is characterized by inherited and polymorphic objects. STL neither
uses nor supports these.
OO is characterised by encapsulated objects that have internal state,
are responsible for their own behaviour and communicate through
message passing. The STL does follow this. This newer definition of OO
centred around inheritance is a direct result of Java and to a lesser
extent C++, but it has no historic basis.
I see little basis for this claim. Consider, for example:
Object-oriented programming is a method of implementation in
which programs are orgainzed as cooperative collections of
objects, each of which represents an instance of some class,
and whose classes are all members of a hierarchy of classes
united via inheritance relationships.
That's from _Object-Oriented Analysis and Design: With Applications
(Second Edition)_, Grady Booch, 1994. In the same book, use of objects
but not inheritance is titled "Object-based".
Going back even further:
A subclass specifies that its instances will be the same
as instances of another class, called its _superclass_,
except for the differences that are explicitly stated.
The Smalltalk-80 programmer always creates a new class as
a subclass of an existing class. A system class named
Object describes the similarity of all objects in the
system, so every class will at least be a subclass of
Object.
_Smalltalk-80: The Language_, Adele Goldberg and David Robson, 1989.
There is little or no historical support for the notion that use of
objects in the absence of inheritance gives object oriented programming.
The Standard Template Library was (and remains) largely template-based
-- but C++ was considered an object-oriented programming language long
before it supported templates at all.
Yes and no. If you analyse how hierarchy is used in the languages
you'll notice that there are fundemental differences. In Smalltalk it
is not possible to use hierarchy for type checking so it is used for
programmer convenience.
If you look at the way that the collection classes in Smalltalk are
implemented you'll notice that they're conceptually similar to the
collection classes in the STL. Smalltalk's collections work with
objects that implement a specific capability/method/operator (which
ones depend on the collection class), not because they are a sub-class
of a specified super-class.
In as much as inheritance is used for type checking it has not been
important in older OO system. For helping the programmer to re-use
code and organise the system it has been important. These days most
people equate hierarchy with type checking and that is what I'm saying
isn't a defining quality of OO.
For what it's worth I think Alan Kay agrees with me:
http://userpage.fu-berlin.de/~ram/pub/pub_jf47ht10Ht/doc_kay_oop_en
You'll notice that he never uses inheritance as part of his
definition.
K