|
 |
 |
 |
|
|
 |
|
|
Design by Contract in Java |
Duration: 3 days |
|
|
- Architects
- Designers
- Developers
- Testers
- Software Process
Designers
- Any stakeholder
in an organization applying technology who wants to understand
the object-oriented promise
|
|
Experience in object-oriented
programming is a must. Knowledge of Java is not essential.
Participants without Java experience are given sufficient guidance to perform
the exercises. |
|
|
Description |
This
course covers the principles and practices of writing precise
contracts for program interfaces. The course begins with contracts
for individual classes, and continues with the additional techniques
necessary to define component interfaces. The course teaches participants
to design conceptual models of classes and components to support
precisely-expressed contracts. The benefits of representing such
contracts in an executable form are explored through carefully-selected
demonstrations and practical exercises in Java (the course can
be customized to other languages). The course addresses the different
roles played by preconditions, postconditions, and invariants
within contracts. Participants each receive a copy of the book
Design by Contract, by Example; published in 2002 by Addison-Wesley,
and written by Dr Richard Mitchell, an InferData Senior Consultant,
and Professor Jim McKim of Rensselaer Polytechnic Institute. |
|
Objectives |
This course teaches
participants to write precise contracts for program interfaces.
On completion of the course, students will be able to:
- Apply the six
principles of design by contract
- Extend a class
or component interface in order to support precise contracts
- Write precise
postconditions on methods or operations in an interface
- Add preconditions
and invariants, where appropriate
- Understand the
relationships between contracts, exceptions, and defensive programming
- Exploit contracts
in software testing
- Transform contracts
to work effectively in distributed environments
- Discuss the
benefits and limitations of contracts
|
|
Course Outline |
The elements of Design by Contract
- Queries, commands and hybrid operations
- Basic queries and derived queries
- Preconditions, postconditions, and invariants
The six principles of Design by Contract
- Basic queries as conceptual models
- Contracts over basic queries
- Extending interfaces to include adequate models
Classes, interfaces and components
- Contracts on classes
- Contracts on program-level interfaces
- Contracts on component interfaces
Contracts and the development process
- Contracts in testing
- Contracts as documentation
- Contracts in production code
|
|
Contracts, exceptions, and defensive programming
- Exceptions as queries vs. exceptions signaling faults
- Contracts in distributed systems
- Contracts vs. defensive programming
Benefits and limitations of contracts
- Documentation and test support: two returns on one investment
- What contracts cannot protect against
- Using contracts without execution-time support
Examples and Exercises
- Practical examples of contracts for classes
- Practical examples of contracts for components
- Laboratory exercises: runtime checking of contracts
| |
|
|