Xref: utzoo comp.object:1454 comp.lang.eiffel:1001 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucsd!hub.ucsb.edu!eiffel!bertrand From: bertrand@eiffel.UUCP (Bertrand Meyer) Newsgroups: comp.object,comp.lang.eiffel Subject: Re: Should a constructor do "work"? Summary: Avoid creating inconsistent objects Message-ID: <364@eiffel.UUCP> Date: 12 Jul 90 19:23:03 GMT References: <55236@microsoft.UUCP> <519@tetrauk.UUCP> Organization: Interactive Software Engineering, Santa Barbara CA Lines: 19 From <519@tetrauk.UUCP> by rick@tetrauk.UUCP (Rick Jones): > How should > the language or the program design cope with a situation where an object is created, but > its create routine ("constructor") is unable to satisfy the invariant due to some > run-time condition which the program must trap in a non-fatal way. In Eiffel an > exception could be raised, and caught somewhere else, but that would not in itself > prevent the existence of the invalid object. If invariants are checked and a creation operation raises an exception, the target of the Create should remain void, excluding any creation of an inconsistent object. This should definitely be part of the language specification. -- -- Bertrand Meyer bertrand@eiffel.com