comp.lang.ada
 help / color / mirror / Atom feed
From: cis.ohio-state.edu!zaphod.mps.ohio-state.edu!wupost!darwin.sura.net!Siriu s.dfn.de!ira.uka.de!unido!alfrat!roy@ucbvax.Berkeley.EDU  (Roy Phillips)
Subject: Re: Multiple Inheritance in Ada 9X
Date: 5 Jan 92 19:54:49 GMT	[thread overview]
Message-ID: <361@alfrat.uucp> (raw)

In article <1991Dec20.094627.6517@iccgcc.decnet.ab.com>, klimas@iccgcc.decnet.a
b.com writes:
> If you're going to implement MI, please study what has been done already
> very closely because there seems to be a uniform story comming back
> from different sources and technologies that the current
> implementations of MI create more troubles than benefits. 

Multiple inheritence is a method of reflecting in software, properties of a
real-world entity to be modelled, exactly as a loop construct might model
a (real-world) iterative process.  If your model (view) requires that a class
is constructed by inheriting two other classes (i.e., the new class has all
the properties of both these classes, with equal importence being given to
both sets of properties), then you cannot reasonable do anything else than use
multiple inheritence - unless you can revise your model.

Multiple inheritence can (and does) cause problems, but only if abused (as can
virtually any programming construct yet invented).  More up-front thinking is
needed - how should a new class relate to existing classes?, how should it be
used and re-used?

Suppose we want to model a new motor vehicle, being at the same time a
sports car and an off-road vehicle.  We can list the major attributes of
both vehicle-classes, add them together, and we've got our off-road sports
car - multiple inheritence seems to reflect this relationship perfectly 
(possibly with repeated inheritence).  On the other hand, if we just
wanted to create a sports-car with 4-wheel-drive, inheriting from both
these classes seems inappropriate - rather create a sport-car descendant
that has 4-wheel-drive as an attribute (possibly by redefining the `final-drive
'
attribute).

Without MI, in the first case we'd need to make off-road-vehicle an attribute
of the sport-car descendant class, which seems wrong.  Whereas using MI in the
second case - if we inherited from sports-car and 4-wheel-drive, we'd end-up wi
th
a class that polymorphism would allow us to use in place of 2-wheel-drive as so
me
other vehicle's `final-drive' - that would look really wierd!

It may be that MI might be to OO languages what pointers were to C - the greate
st
power and the greatest danger.

--
Roy Phillips
A+F SystemEntwicklung
W-4030 Ratingen
Germany
roy@alfrat.de
{world}!mcsun!unido!alfrat!roy

             reply	other threads:[~1992-01-05 19:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-01-05 19:54 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!wupost!darwin.sura.net!Siriu [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-01-10 14:48 Multiple Inheritance in Ada 9X mcsun!fuug!news.funet.fi!sunic!ugle.unit.no!nuug!ifi.uio.no!holmenkollen!
1992-01-02 21:31 Dan Weinreb
1991-12-31 11:00 Bob Hathaway
1991-12-30 20:10 Dan Weinreb
1991-12-30 20:01 Dan Weinreb
1991-12-29 19:38 bu.edu!inmet!inmet!stt
1991-12-29  6:19 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!think.com!barmar
1991-12-29  0:15 Object Systems
1991-12-27 21:40 Bjarne Stroustrup
1991-12-26 15:29 icd.ab.com!iccgcc.decnet.ab.com!klimas
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox