Templated containers of inherited objects

E

Emmanuel Deloget

Hm, I always felt that this is simply because pointers are not really what
we want when dealing with objects. What we want is something like a
reference that can be assigned and re-seated. Something like this:

tr1::reference_wrapper? It will be incorporated in the next standard,
so let's use it (provided that those damn major compiler vendor gives
us a valid implementation of the tr1. As of today, it's quite hard to
use it in a portable way).

-- Emmanuel Deloget
 
?

=?iso-8859-1?q?Kirit_S=E6lensminde?=

[ ... ]
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top