Path: utzoo!attcan!uunet!tektronix!tekecs!nobody From: nobody@tekecs.TEK.COM (-for inetd server command) Newsgroups: comp.lang.misc Subject: Re: object oriented design decision Message-ID: <10660@tekecs.TEK.COM> Date: 22 Nov 88 20:47:14 GMT References: <4086@enea.se> <11522@cup.portal.com> <12636@steinmetz.ge.com> Reply-To: paulsc@radio_flyer.UUCP (Paul Scherf) Organization: Tektronix, Inc., Wilsonville, OR Lines: 34 In article <12636@steinmetz.ge.com> halverson@crd.ge.com (Pete Halverson) writes: >From my experience, multiple inheritence seems to be most useful when >you're trying to represent characteristics that are somehow orthogonal, >i.e. land vehicles vs. sea vehicles, motorized vs. non-motorized, military >vs. commercial. Single-inheritance-only schemes require you to define a >separate class for each combination (i.e. Motorized-Military-LandVehicle, >NonMotorized-Commercial-SeaVehicle). If you have many dimensions and many >subclasses, the resulting cross-product is going to get real nasty, real >fast. > >Not to say these kinds of systems aren't complex (I'm currently in the >midst of trying to decipher the Symbolics window class structure) but >multiple inheritance can at least directly represent these orthogonalities. I'm not really "for" or "against" multiple inheritance, but I haven't seen anything that shows that multiple inheritance really adds anything. Couldn't you have one vehicle class with 3 instance variables? One instance variable for each of the "dimensions" (e.g. surface: land vs. sea, propulsion: motorized vs. non-motorized, ...). The vehicle class could forward messages to the appropriate instance variable. Some OO languages allow methods to be expanded in line, and can often avoid the extra method lookup, so that the forwarding wouldn't have to incur a run time penalty. Adding, for example, more surfaces for vehicles (e.g. add to land and sea the surfaces air, space, ...) wouldn't have to require changes to the vehicle class. This doesn't seem to have the cross-product effect you were talking about. Or maybe I just didn't understand the problem, Paul Scherf, Tektronix, Box 1000, MS 61-028, Wilsonville, OR, USA paulsc@orca.GWD.Tek.COM tektronix!orca!paulsc