Xref: utzoo comp.lang.eiffel:1366 comp.object:2493 Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!dkuug!iesd!iesd.auc.dk!amanda From: amanda@iesd.auc.dk (Per Abrahamsen) Newsgroups: comp.lang.eiffel,comp.object Subject: Re: Inheritance and Information Hiding Message-ID: Date: 2 Feb 91 18:48:01 GMT References: <1991Jan23.224203.3206@runx.oz.au> <120021@gore.com> Sender: news@iesd.auc.dk (UseNet News) Organization: Games Research, University of Aalborg, Denmark Lines: 33 In-reply-to: jacob@gore.com's message of 1 Feb 91 16:30:48 GMT Sorry to interrupt, but why does nobody accept Bertrand Meyers first two solutions? >>>>> On 1 Feb 91 16:30:48 GMT, jacob@gore.com (Jacob Gore) said: Jacob> However, if POLYGON's 'add_vertex' contains in its contract the Jacob> postcondition "num_vertices = num_vertices + 1", there is no Jacob> way RECTANGLE can uphold the contract. But in that case a RECTANGLE is not, conceptually, a POLYGON. There are then two possibilities (as Bertrand Meyer mentioned in <488@eiffel.UUCP>: 1) The postcondition in correct: You can always add a vertex to a polygon. In this case, a rectangle is not a polygon, and it is misleading to use inheritance. 2) The postcondition is wrong. You can only add a vertex to some kinds of polygons. If the postcondition is wrong, it should be fixed, like any other bug! In a program which should be read and understood by other people later, these are the only long term solutions. However, when you are creating a throw away prototype, inheritance might be useful nonetheless. In this case, it does not matter much whether the language provides "implementation inheritance (solution 3), "extended type check" (solution 4), or "run time check" (solution 5), except that (5) is the most flexible, and (3) the most safe.