Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!bony1!richieb From: richieb@bony1.uucp (Richard Bielak) Newsgroups: comp.lang.eiffel Subject: RE: Exceptions and Assertions Keywords: eiffel exceptions assertions preconditions Message-ID: <1990Sep7.032121.6456@bony1.uucp> Date: 7 Sep 90 03:21:21 GMT Reply-To: richieb@bony1.UUCP (Richard Bielak) Organization: Bank of New York Lines: 48 I have two comments on recent postings, regarding exceptions and assersion in Eiffel. Speaking of exceptions, Rick Jones writes: >One of Eiffel's most powerful features is its exception handling, and in my >current work I am experimenting with a programming style which places heavy >reliance on this system. The general concept is that _all_ "non-normal" >conditions are treated as exceptions, including those which may be expected to >occur quite frequently. IMHO, pushing non-normal cases into exception handlers is wrong. An exception should only be used to handle the cases that were not forseen by the developer. Doing a "raise" and handling a condition elsewhere in the program has two problems: 1) Flow of the code is hidden from the programmer reading the code; a "raise" is almost as bad as a GOTO. 2) If too much code is put in an exception handler, what will happen if the handler encounters an exception? My other comment is on precondition checking. Preconditions are placed in a routine to make it more re-usable. Some clients may do a extra check, others may not. If some checks are occasionally duplicated - well, that's the price you pay for re-usable software. In his reply, Bertrand Meyer asks: >Should we tend towards a situation where precondition checking >will always be on, even in a released software product? Yes! Yes! Yes! A million times yes! Let's use those MEGA-MIPS for something useful. I don't believe we can ever write software that is error free, we can at least write software that detects errors before doing too much damage. Hardware detects errors, why not software? ...richie -- +----------------------------------------------------------------------------+ || Richie Bielak (212)-815-3072 | If it happens, || || USENET: richieb@bony.com | it is possible! || +----------------------------------------------------------------------------+