Xref: utzoo comp.lang.eiffel:1349 comp.object:2473 Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!think.com!spool.mu.edu!uunet!mcsun!ukc!pyrltd!tetrauk!rick From: rick@tetrauk.UUCP (Rick Jones) Newsgroups: comp.lang.eiffel,comp.object Subject: Re: Inheritance and Information Hiding Message-ID: <1080@tetrauk.UUCP> Date: 31 Jan 91 09:49:14 GMT References: <1991Jan23.224203.3206@runx.oz.au> <1991Jan24.214652.18515@Think.COM> <808@puck.mrcu> <10612@pasteur.Berkeley.EDU> Reply-To: rick@tetrauk.UUCP (Rick Jones) Organization: Tetra Ltd., Maidenhead, UK Lines: 35 Given that this thread is starting to look like an Eiffel v C++ debate, there is a significant aspect of Eiffel which has been overlooked - assertions. One of the concepts of Eiffel is that the properties of a class may (and should) be specified in terms of the class invariant and pre- and post-conditions of routines. When using inheritance to write a new class, you can access and/or redefine anything in the parent class, but you cannot override the assertions. (In the current version you can override the pre- and post-conditions, but this is a recognised compiler problem which is going to be rectified.) You certainly can't override the invariant, but you can strengthen it by adding additional invariant properties. The correct way to use Eiffel is to be rigorous with the use of assertions, and run all your tests with all assertion checking on. The assertion checking may then be turned off for a production version once you are sure that the assertions never get violated. This is a sometimes subtle but significantly different approach to the problem of protecting the semantics of classes, and avoids the need to hide the implementation details from descendant classes. You can look at it by saying that the interface of a class is public, the implementation is protected, and the assertions are private (it's not an exact analogy, but it gives the right feel). Of course you have to get your assertions correct, but I don't believe that is any harder than getting the public/private/protected bit right. I have already had several occasions to be glad of Eiffel's assertion system, since it has been able to nip in the bud a number of errors which would otherwise have gone unnoticed and become obscure time-bomb bugs. -- Rick Jones Tetra Ltd. Maidenhead, Was it something important? Maybe not Berks, UK What was it you wanted? Tell me again I forgot rick@tetrauk.uucp -- Bob Dylan