Xref: utzoo comp.lang.eiffel:1426 comp.object:2596 Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!bellcore!maya!caseau From: caseau@maya.bellcore.com (Yves J Caseau) Newsgroups: comp.lang.eiffel,comp.object Subject: Re: Inheritance and Information Hiding Message-ID: <1991Feb5.130359.9735@bellcore.bellcore.com> Date: 5 Feb 91 13:03:59 GMT References: <488@eiffel.UUCP> <27A86309.281A@tct.uucp> <1991Feb1.135956.12425@tukki.jyu.fi> <27ADD06B.46A3@tct.uucp> Sender: usenet@bellcore.bellcore.com (Poster of News) Reply-To: caseau@maya.UUCP (Yves J Caseau) Organization: Bell Communications Research, Morristown NJ Lines: 35 Here is my $0.02 contribution to the problem: ============================================= 1. This is a well-known and common problem. In the type theory and object-oriented database community, the example is a class point with an instance variable x, and the subclass is the set of point for which x is between 0 and 10. So if we change the instance variable, the "class" to which the object belongs must change, or an error must be detected. The question is: given a class A, and a subclass B which has a characteristic property, how to represent it into an object-oriented system? Obviously it depends if your system supports such characteristic properties. If it does (Eiffel with invariants, Semantic networks with specialisation predicates (eg CLASSIC), LORE with selection sets, FOL-based object-oriented systems) you have a "nice" solution: inheritance with automatic error detection (Eiffel: the invariant is violated) or reclassification. If the system does not support such properties, you have to implement them yourself, copying one of the two previous solutions. This means that each method that returns an object from B must be specialized (if it is inherited) so as to check the characteristic property (and decide between error or re-classification, according to the language features (C++ vs. CLOS) 2. My solution to the POLYGON/RECTANGLE problem. I tend to be simple minded: a. a RECTANGLE is a POLYGON (thefore there must be inheritance) b. Adding a vertex to a polygon produces ANOTHER polygon (a different mathematical object) c. Thus, rectangle inherit the property add_vertex, which produces a pentagone from a rectangle Don't flame me on this, I know this is cheating ... but it makes a lot of sense. Brought to you by Super Global Mega Corp .com