Instructor's Guide
introduction
themes
paradigms
lifecycle
trends
summary
Q/A
literature
There is a close similarity between the object model as presented earlier
and the notion of abstract data types just described.
Both objects and abstract data types define a set of applicable
operations that completely determine the behavior of an object or an
element of the data type.
To relate an object to an abstract data type we need the notion of class,
that serves as the description on an abstract level of the behavior of (a collection of)
objects. (The objects are called the instances of the class.)
As noted in [St88], abstract data types as such, although mathematically satisfying,
are rather inflexible and inconvenient for specifying complex software systems.
To attain such flexibility, we need to be able to organize
our types and express the commonality between them.
The notion of class supports this by a mechanism called inheritance.
When regarding classes as types, inheritance may be seen
as introducing polymorphic types.
A class that is derived from a particular class (the base class)
may be treated by the compiler as a subtype of (the type of)
that particular class.
See slide [1-oo-support].
Support for OOP
- Polymorphism -- inheritance
Inheritance
- dynamic binding
- protection
- multiple inheritance
slide: Support for OOP
Operationally, the power of inheritance comes from
message dispatching.
This mechanism is called dynamic binding.
Message dispatching
takes care of selecting the right method in response
to a message or method call.
In a hierarchy of (derived) classes, a method for an object
may be either defined within the class
of the object itself or by one of the classes from which
that class is (directly or indirectly) derived.
Message dispatching is an essential mechanism for supporting
polymorphism, since it allows to choose the most appropriate
behavior for an object of a given type.
This must occur at runtime, since the type of an object
as determined at compile-time may be too general.
An important issue in determining whether a language
supports object-oriented programming is whether
it offers a protection mechanism to shield
the vulnerable parts of a base class from the classes
that derived from that class.
Another question of interest is whether a language must support
multiple inheritance.
Clearly, there is some disagreement on this issue.
For example, Smalltalk-80 and Java do not support
multiple inheritance.
The Eiffel language, on the other hand, supported
multiple inheritance from its first days.
For C++, multiple inheritance was introduced
at a later stage.
At first, it was thought to be expensive
and not really necessary.
Closer analysis, however, revealed that the cost was not
excessive. (See Ellis and Stroustrup, 1990.)
The issue of multiple inheritance is still not
resolved completely.
Generally, it is acknowledged to be a powerful
and at the same time natural extension of single inheritance.
However, the inheritance mechanism itself seems to be
under attack.
Some doubt remains as to whether inheritance is a suitable
composition mechanism when regarded from the perspective of
reuse and reliability.
An elegant solution is provided by Java which
offers multiple interface inheritance, by allowing
multiple interfaces to be realized by an
actual class.