SPA Conference session: Design by Contract in Java

One-line description:Learn six principles for writing contracts, and practice them on a Java example
 
Session format: Tutorial (150 mins) [read about the different session types]
 
Abstract:Design by Contract involves adding contracts to classes and their methods. These contracts are between those who implement classes and those who write clients of classes. The contracts are expressed as assertions (preconditions, postconditions, and invariants). Good contracts improve documentation and help with testing.

The six principles covered in the tutorial will help you write good contracts. The tutorial will also help you understand the relationship between contracts and exceptions.
 
Audience background:Those attending should:
- be able to write simple programs in Java
- want to explore writing precise documentation of classes.
 
Benefits of participating:- Learn six principles of writing good contracts.

- Understand how contracts support testing.

- Understand how contracts provide trustworthy documentation.

- Understand the relationship between contracts and exceptions.

- Practice writing contracts for one or more Java classes.
 
Materials provided:The presenter will provide:

- slides (including canned results of a demo of design by contract)

- planned exercises
 
Process:The session will have 4 main parts:

Part one - setup (about 30 mins)

Part two - learning and practising the principles (about 60 mins). As each principle is taught via one example, attendees will apply it to another example.

Part three - exceptions (about 20 mins)

Part four - discussion or practice (about 30 mins)
 
Detailed timetable:
 
Outputs:The session outputs will be:

- the slides

- a poster recording any insights generated during discussions (such as when design by contract has a high payoff)
 
History:An Eiffel version of the tutorial was presented some years ago. The proposed Java version arises from current work on a Java edition of the book "Design by Contract". The Java material has largely been tested on captive audiences on InferData's Advanced OOAD courses.
 
Presenters
1. Richard Mitchell
InferData Ltd and Mitchell Horvath Ltd
2. 3.