UML Operation Contract
A UML Operation contract identifies system state changes when an operation happens. Effectively, it will define what each system operation does. An operation is taken from a system sequence diagram. It is a single event from that diagram. A domain model can be used to help generate an operation contract. The domain model can be marked as follows to help with the operation contract:
1. Green - Pre existing concepts and associations.
2. Blue - Created associations and concepts.
3. Red - Destroyed concepts and associations.
Operation Contract Syntax
Responsibilities: Perform a function
Cross References: System functions and Use Cases
Preconditions: Something or some relationship exists
Postconditions: An association was formed
When making an operation contract, think of the state of the system before the action (snapshot) and the state of the system after the action (a second snapshot). The conditions both before and after the action should be described in the operation contract. Do not describe how the action or state changes were done. The pre and post conditions describe state, not actions. Typical postcondion changes:
1. Object attributes were changed.
2. An instance of an object was created.
3. An association was formed or broken.
Postconditions are described in the past tense. They declare state changes to the system. Fill in the name, then responsibilities, then postconditions.