UML Sequence Diagrams
11. System Operations Contracts
Use cases describe system
behavior which is usually sufficient. But, sometimes a more detailed
description of system behavior is needed. Again system sequence diagram does
not describe the effect of the execution of an operation invoked. It is missing
the details necessary to understand the system response – the system behaviour.
Part of the understanding of the system behaviour is to understand the system
state changes carried out by system operations. A system state is a snapshot of
the system at a particular moment of time which describes the objects of
classes currently existing, current values of attributes of these objects, and
current links between the objects at that time. The execution of a system
operation changes the system state into another state:
- Old objects may be removed,
- New objects and links may be created, and
- Values for attributes of objects may be modified.
To describe detailed system behavior in terms of state changes to objects in the Domain Model, after a system operation has executed, contracts are being used. We need to know how to write a contract for a system operation. As explained by Liu, the contract of an operation is defined mainly in terms of its pre-conditions and post-conditions.
- Pre-conditions are the conditions that the state of the system is assumed to satisfy or must hold true before the execution of the operation
- Post-conditions are the conditions that the system state has to satisfy when the execution operation has finished, or the constraint that must hold true after the completion of an operation.