Page 20 : 32
Object-oriented Programming in C#
Contracts and Assertions
* Correctness
Software Qualities
Correctness
Specifications
* Specification with preconditions and postconditions
Logical expressions
Examples of preconditions and postconditions
An Assertion Language
* Responsibilities and Contracts
Questions Related to Responsibility
Division of Responsibilities
The highly responsible program
Responsibility division by pre and postconditions
Contracts
Everyday Contracts
Contracts: Obligations and Benefits
Obligations and Benefits in Sqrt
* Class Invariants
General aspects of contracts
Everyday invariants
An example of a class invariant
* Inheritance is Subcontracting
Inheritance and Contracts
Subcontracting
Class invariants in the triangle class hierarchy
Assertions in Abstract classes
* Design by Contract
Design by Contract
DBC and Programming Languages
Code Contracts in C# 4.0
* Loop Invariants
Loop Invariants
Everyday invariants
Adherence to invariants is the key to order in our daily lives
Coffee Machine
In between operations there is always at least one cup of coffee available
Toilet
In between "transactions" there is always at least 0.75 meter of toilet paper on the roll
Keys and wallet
In between using keys and/or wallet
During daytime: Keys and wallet are in the pocket
During nighttime: Keys are wallet are located on the bedside table or underneath the pillow