From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=0.8 required=3.0 tests=BAYES_50,MSGID_SHORT autolearn=no autolearn_force=no version=3.4.5-pre1 Date: 5 Jan 92 19:54:49 GMT 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 Message-ID: <361@alfrat.uucp> List-Id: 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