Path: utzoo!utgpu!watserv1!watmath!att!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!ncar!boulder!gore!jacob From: jacob@gore.com (Jacob Gore) Newsgroups: comp.lang.eiffel Subject: Subcontracting vs. Parents' Invariant rule Message-ID: <120020@gore.com> Date: 30 Oct 90 01:38:49 GMT Reply-To: jacob@gore.com (Jacob Gore) Organization: Gore Enterprises Lines: 25 (If this has been discussed already, I'd appreciate a copy of the relevant articles(s).) Programming by Contract says that if C2 is a subclass of C1, then C2.r (inventing some syntax here) must be a subcontractor for C1.r (assume no renaming). This means that the precondition of C2.r must be no more restrictive than the precondition of C1.r, and the postcondition of C2.r must be no more liberal than the postcondition of C1.r . Then there's the class invariant. Class Correctness rule implies that it is both a precondition and a postcondition for every routine (except during creation). So, to keep subcontracting happy, the invariant of C2 can be neither more restrictive than that of C1 (to satisfy the subcontracting restriction on preconditions) nor more liberal (to satisfy the subcontracting restriction on postconditions). But the Parent Invariant Rule says that the invariant of C1 can be more restrictive than that of C2. Does this not conflict with subcontracting? Does this not mean that an object of class C2, when dynamically bound to a variable of type C1, may be used under conditions that violate its class's invariant? Jacob -- Jacob Gore Jacob@Gore.Com boulder!gore!jacob