Lecture overview -- Keyboard shortcut: 'u'  Previous page: Specification with preconditions and postconditions [Section] -- Keyboard shortcut: 'p'  Next page: Examples of preconditions and postconditions -- 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 6 : 32
Object-oriented Programming in C#
Contracts and Assertions
Logical expressions

A logical expression is an expression of type boolean

An assertion is a logical expression, which, if false, indicates an error [Foldoc]

A precondition of an operation is an assertion which must be true just before the operation is called

A postcondition of an operation is an assertion which must be true just after the operation has been completed

  • Precondition

    • A precondition states if it makes sense to call an operation

    • The precondition is a prerequisite for the activation

  • Postcondition

    • A postcondition states if the operation returns the desired result, or has the desired effect, relative to the given parameters that satisfy the precondition

    • The postcondition defines the meaning of the operation