Xref: utzoo comp.object:2521 comp.lang.eiffel:1382 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!visix!news From: adam@visix.com (Adam Kao) Newsgroups: comp.object,comp.lang.eiffel Subject: Re: Inheritance and Information Hiding Message-ID: <1991Feb7.061215.10966@visix.com> Date: 7 Feb 91 06:12:15 GMT References: <488@eiffel.UUCP> <27A86309.281A@tct.uucp> Sender: news@visix.com Reply-To: adam@visix.com (Adam Kao) Organization: Visix Software Inc., Reston, VA Lines: 59 Barbara Lerner writes: > The distinction between adding a vertex to a polygon and adding a > vertex to a rectangle is the following. When a vertex is added to a > polygon, no new object is created. The same polygon object exists but > has one more vertex. > If we take the point of view that we can add a vertex to a rectangle > with the result begin a pentagon, we now have two choices: > 1. Create a new Pentagon object that is a "copy" of the rectangle > with the added vertex. > 2. Add the vertex to the rectangle object, and change its class > from rectangle to pentagon. Hmm, I guess I did gloss over this distinction. I do understand the uses and problems of sharing mutable objects. Choice (1) defines nonshared or immutable use, choice (2) defines mutable use. I see these choices as complementary. Our problem with (2) is that someone else can modify the shared object in ways which I consider illegal. All users of the object should agree on the set of allowed changes. A. A Class must support all operations of its Parent Class. B. A Class must enforce all invariants that users wish to preserve on member Objects. (Allowing (2) makes Class RECTANGLE differ from our specific abstract rectangle class in the sense defined by (B). Class membership in the programming sense is actually only one of many possible invariants that we might wish to maintain to define an abstract class.) These goals conflict, which leads me to say that our notion of Class cannot support all the uses we expect. (A) and (B) are different questions; they lead to different classification schemes. If we choose to preserve (A), then Siblings will be able to change into each other. If we choose to preserve (B), then Classes specialize their Parents by reducing the allowed transformations. Any solution that tries to define a singular Class concept satisfying both (A) and (B) will be non-intuitive, at best. Adam > Barbara Staudt Lerner > Deparment of Computer and Information Science > Lederle Graduate Research Center > University of Massachusetts > Amherst, MA 01003 > blerner@cs.umass.edu PS I notice you edited the followup line to comp.lang.eiffel. Unfortunately, I know almost nothing about eiffel. I would rather continue this discussion in comp.object, or, if you feel it is more appropriate, via email.