Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!usc!henry.jpl.nasa.gov!elroy.jpl.nasa.gov!jpl-devvax!david From: david@jpl-devvax.JPL.NASA.GOV (David E. Smyth) Newsgroups: comp.object Subject: Inheritance IS NOT Delagation!!!!! Summary: except in non-concurrent systems. Message-ID: <6219@jpl-devvax.JPL.NASA.GOV> Date: 12 Oct 89 22:48:28 GMT References: <125984@sun.Eng.Sun.COM> <17653@brunix.UUCP> Reply-To: david@jpl-devvax.JPL.NASA.GOV (David E. Smyth) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 58 In article <17653@brunix.UUCP> sdm@norton.UUCP (Scott Meyers) writes: >In article <125984@sun.Eng.Sun.COM> grover%brahmand@Sun.COM (Vinod Grover) writes: >>I once read that the inheritence mechanism is a special case of a more >>general phenomena called Delegation. I cannot come up with the reference >>but unless I am mistaken I think it was an article written by Stefik and >>Bobrow in the AI Magazine a few years ago. > >Lynn Stein, a graduate student here at Brown, proved that delegation and >inheritance are equivalent. Hence, inheritance is not a "special case" of >delegation. For the proof, see her paper in the OOPSLA '87 Proceedings: >"Delegation Is Inheritance." Delagation is better than Inheritance, because 1) Inheritance violates encapsulation by the superclasses, therefore 2) Inheritance makes concurrency more difficult in the resultant system. Note: "Actors" which is the most widely accepted language concept for concurrent object programming, DOES NOT support concurrency. Using delagation, one builds a complex "object" through grouping several different small objects together. Each small object maintains its own address space and thread. The complex object is only conceptual. Delagation reflects reality better than inheritance: your car does not inherit from door, tire, and engine: is is a composite made up of doors, tires, and an engine. The fact that the window on the left door is open should have no bearing on the state of other windows or the fuel injection or tire pressure. Concurrency is more cleanly supported with Delagation than with Inheritance. Imagine a Car class built using multiple-inheritance. Building the car would require the constructors to be invoked serially, OR the programmer would have to be concerned about critical sections and the like. As we all know, critical sections are notoriously hard to find and debug. The reason time sharing systems are so easy to use is this: all of the processes get their own address space. The encapsulation provided by objects is exactly the same, but the granularity is finer. This leads to more effective use of multi-processors and multi-threaded processes (ala Mach). In fact, one can think of the object universe which represents the typical object-oriented application as being a bunch of delagating objects. The average depth of inheritance in most systems is about 3. The number of object types in many systems is very large, in the dozens to thousands. Therefore, people tend to favor delagation over inheritance by a large margin, even when they don't consider it to be an issue. Can you imagine the nightmare which would result if all the objects in YOUR application were cobbled together via inheritance into a single object type? Barfo dude! Sure, a graduate student can "prove", that "Inheritance IS Delagation" but is is obviously the inferior form of the duality. Lynn Stein would have met with alot of disagreement if that paper was presented at OOPSLA '89.