Xref: utzoo comp.lang.eiffel:1421 comp.object:2578 Path: utzoo!attcan!uunet!zephyr.ens.tek.com!tekchips!tekcrl!brucec From: brucec@phoebus.labs.tek.com (Bruce Cohen;;50-662;LP=A;) Newsgroups: comp.lang.eiffel,comp.object Subject: Re: Inheritance and Information Hiding Message-ID: Date: 1 Feb 91 21:30:14 GMT References: <10612@pasteur.Berkeley.EDU> <485@eiffel.UUCP> <488@eiffel.UUCP> <1991Jan31.185534.24530@Think.COM> Sender: news@tekchips.LABS.TEK.COM Followup-To: comp.lang.eiffel Organization: Tektronix Inc. Lines: 48 In-reply-to: barmar@think.com's message of 31 Jan 91 18:55:34 GMT In article <1991Jan31.185534.24530@Think.COM> barmar@think.com (Barry Margolin) writes: > ... > Furthermore, some languages (e.g. CLOS) even allow the class of an object > to change dynamically, so there's another solution: > > 6. As in 5, use virtual function inheritance of add_vertex. > RECTANGLE::add_vertex would change the class of self to POLYGON and then > call self.add_vertex (which will invoke the POLYGON::add_method, which > might further change the class to PENTAGON). > > In fact, schemes like this may be the only sensible way to implement a > system of this type. Consider a context in which the above classes would > be used: a graphical drawing program. The user clicks on an object and > then selects an operation from a menu (or vice versa). Solution 6 would be > useful if you want to allow users to use the rectangle tool to create an > object, but later permit them to edit it in such a way that it is no longer > a rectangle. There was a lengthy and somewhat inconclusive discussion in this newsgroup a few months ago of just this scheme in relation to using Self for a graphic system. I started it by noting that Self allows this technique in a graphic system (I hadn't had any real experience with CLOS at the time, especially the MetaObject Protocol). As mentioned then, there are additional benefits to changing the inheritance of an object dynamically: tailoring the space and/or time complexity of operations on the object to match its current needs (e.g., rectangles which are orthogonal to the coordinate axis can be drawn faster than other polygons on many systems). Structure objects (graphic container objects with semantics about how they display their contained graphics) can change their semantics easily. This is handy for modifying the rendering of contained objects in job lots. Most of the benefits are a result of the size and dynamic complexity of graphics, especially 3D photorealistic graphics. It's not at all uncommon to have a system containing hundreds of thousands or millions of primitive graphic objects, arranged in many complex structures. Space and time savings at rendering time become very important in these systems; it's usually a good tradeoff to lose some time in dynamically modifying the objects in an editing phase. -- ------------------------------------------------------------------------ Speaker-to-managers, aka Bruce Cohen, Computer Research Lab email: brucec@tekchips.labs.tek.com Tektronix Laboratories, Tektronix, Inc. phone: (503)627-5241 M/S 50-662, P.O. Box 500, Beaverton, OR 97077