Lecture overview -- Keyboard shortcut: 'u'  Previous page: Class Invariants [Section] -- Keyboard shortcut: 'p'  Next page: Everyday invariants -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 19 : 32
Object-oriented Programming in C#
Contracts and Assertions
General aspects of contracts

A class invariant expresses some constraints that must be true at every stable point in time during the life of an object

A class invariant expresses properties of an object which are stable in between operations initiated via the public client interface

  • A class invariant

    • acts as a general strengthening of both the precondition and postcondition

    • expresses a "health criterion" of the object

    • must be fulfilled by the constructor

    • must be maintained by the public operations

    • must not necessarily be maintained by private and protected operations