Trace a monitored call

A language runtime monitors contracts while a client calls one public routine on an object. The monitor follows the usual rule that old expressions are evaluated only for a legal call, so that evaluating them can rely on the precondition. Put the events of this single call in the order they happen, from the client preparing the call to the client using the result.

  1. 1.

    The routine body executes.

  2. 2.

    The monitor checks the class invariant and the precondition on entry.

  3. 3.

    The client relies on the postcondition in its next statement.

  4. 4.

    The monitor saves the entry values that the postcondition's old expressions refer to.

  5. 5.

    The client establishes the precondition and calls the routine.

  6. 6.

    The monitor checks the postcondition and the class invariant on exit.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Design by Contract Questions: