University of Virginia, Department of Computer Science
CS201J: Engineering Software, Fall 2003

Notes: Tuesday 21 October 2003
Schedule

Substitution Principle:

B is a subtype of A means wherever an object of type A isexpected, we can use an object of type B instead.

For a function f (A), if f satisfies its specification when passed an object whose actual type is type A, f also satisfies its specification when passed an object whose actual type is B.

Signature Rule

Java's rule is stricter (novariant) — subtype signatures must match supertype signatures (except the subtype may throw fewer exceptions).

Methods Rule

Properties Rule — Subtype must preserve all properties in the supertype's overview specification.
         class A { public RA m (PA p) ; }
         class B extends A { public RB m (PB a); }

               Substitution Principle             Eiffel

Parameters     PB >= PA	                 PB <= PA
Preconditions  pre_A implies pre_B       pre_B implies pre_A

Result         RB <= RA                  RB <= RA
Postconditions post_B implies post_A     post_B implies post_A

Must it be assumed that because we are engineers beauty is not our concern,
and that while we make our constructions robust and durable we do not also strive to make them elegant?
Is it not true that the genuine conditions of strength always comply with the secret conditions of harmony?
Gustav Eiffel


CS201J University of Virginia
Department of Computer Science
CS 201J: Engineering Software
Sponsored by the
National Science Foundation
cs201j-staff@cs.virginia.edu