Xref: utzoo comp.lang.eiffel:1401 comp.object:2548 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!mcsun!ukc!tcdcs!bofin!cjmchale From: cjmchale@cs.tcd.ie (Ciaran McHale) Newsgroups: comp.lang.eiffel,comp.object Subject: Re: Inheritance and Information Hiding Message-ID: <1991Feb10.203124.456@cs.tcd.ie> Date: 10 Feb 91 20:31:24 GMT References: <1991Feb8.171341.19413@cs.tcd.ie> <2140@cs.rit.edu> <498@eiffel.UUCP> Organization: DSG, Dept. of Comp. Sci., Trinity College, Dublin. Lines: 61 This discussion has used a concrete example (involving polygons, rectangles and an add_vertex operation) to discuss an issue. From the top of my head I can recall the following approaches being suggested: o Having the add_vertex operation in polygon makes that class too specialised to be used as a superclass for rectangle. Reorganise the class hierarchy a bit to solve the problem. o The problem can be solved if the language allows an object to change its type at run-time. Thus applying add_vertex to a rectangle changes that object into a (pentagon or a) polygon. o Rectangle.add_vertex should be a null operation. o Rectangle.add_vertex should raise an exception. o Have very fine grain multiple inheritance. o Have a read_only interface to each class. The read_only interface for polygon would exclude add_vertex, and this resultant class is then suitable as a superclass for rectangle. (I'm sure that other approaches were discussed too.) Then I add in my $0.02 worth suggesting: o If a language has separate type and implementation hierarchies then rectangle can reuse code from polygon without having to support add_vertex in its type. Bertrand Meyer (article <498@eiffel.UUCP>) replies with: >This is simply to point out that the issue of ``implementation >reuse'' versus ``specification reuse'' has nothing to do >with this whole discussion. Why not? It _is_ an approach to solving the problem at hand. It may not be the best approach but I don't see why you are so eager to dismiss it out of hand. >The separation between concept and implementation in software is >an historical evil, not a desirable situation. With a good notation we >can remove the difference. >[...] >One day we will stop being ashamed of implementation, >not because we will have removed the need for implementation >but for exactly the opposite reason: with us, everything >is the implementation. I don't know how (in)correct you are. Only time will tell. But just because you feel that way does not mean that others share your beliefs. So until separation-between-type-and-implementation is widely accepted to be a bad idea, why not consider it where it might be useful? Ciaran. -- Ciaran McHale "Verbosity says it all" ____ Department of Computer Science, Trinity College, Dublin 2, Ireland. \ / Telephone: +353-1-772941 ext 1538 FAX: +353-1-772204 \/ Telex: 93782 TCD EI email: cjmchale@cs.tcd.ie