Page 15 : 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 Contracts
Contracts are all around us in our everyday life
Student and University
The student enrolls some course
The university offers a teacher, a room, supervision and other resources
Citizen and Tax office
The citizen does a tax return
The tax office calculates the taxes, and regulates the paid amount of money
Football player and Football club
The player promises to play 50 games per season
The football club pays 10.000.000 kroner to the player pr. month
Citizen and Insurance company
The insurance holder pays the insurance and promises to avoid insurance fraud
In case of a damage or accident, the insurance company pays compensation