3. Specification Structure

A specification of a method consists of several clauses:

The precondition is an obligation on the client (i.e., the caller of the method). It’s a condition over the state in which the method is invoked.

If the precondition does not hold, the implementation of the method is free to do anything.

The postcondition is an obligation on the implementor of the method. If the precondition holds for the invoking state, the method is obliged to obey the postcondition by returning appropriate values, throwing specified exceptions, etc.

The frame condition identifies which objects may be modified. If we say modifies x, this means that the object x, which is presumed to be mutable, may be modified, but no other object may be.

Omitted clauses: