| name | operation-contracts |
| description | Specifies system operation effects. Use when a system operation has non-trivial state changes, business rules, created objects, associations, or postconditions that use-case text does not capture precisely. |
Operation Contracts
Overview
Operation contracts define what a system operation guarantees, especially changes to domain state. They bridge black-box requirements and object design.
When to Use
- SSDs reveal system operations with complex effects.
- A use case changes multiple domain objects or associations.
- Designers need exact postconditions before assigning responsibilities.
- Do not write contracts for trivial reads or operations already obvious from the use case.
Workflow
- Select the operation. Use an operation from a system sequence diagram.
- Name the operation and scope. Include parameters and the owning system boundary.
- State preconditions sparingly. Only include conditions assumed true before the operation starts.
- Write postconditions as state changes. Capture created/deleted instances, changed attributes, formed/broken associations, and recorded events.
- Use domain model vocabulary. Contracts should reference conceptual objects, not implementation classes.
- Avoid algorithm steps. State what must be true after the operation, not how to implement it.
- Update the domain model. If a postcondition needs a missing concept or association, revise the domain model.
- Use contracts to drive design. Feed postconditions into GRASP responsibility assignment.
Output Template
## Contract: [operation(parameters)]
Operation: [name(parameters)]
Cross References: [Use case, SSD step]
Preconditions:
- [Condition that must already be true]
Postconditions:
- [Instance] was created/deleted.
- [Association] was formed/broken.
- [Attribute] became [value or relationship].
- [Event or transaction] was recorded.
Open Issues:
- [Question affecting design]
Red Flags
- Postconditions are written as procedural implementation steps.
- The contract references controllers, services, repositories, or database tables.
- Preconditions repeat ordinary validation instead of true assumptions.
- Contracts are written for every operation by default, including simple queries.
Verification