Operation Contracts

Sometimes a more detailed or precise description of system behavior has value. Operation contracts use a pre- and post condition form to describe detailed changes to objects in a domain model. A domain model is the most common OOA model, but operation contracts and state models can also be useful OOA-related artifacts.

Operation contracts may be considered part of the Use-Case Model because they provide more analysis detail on the effect of the system operations implied in the use cases.

The prime inputs to the contracts are the system operations identified in SSDs, the domain model, and domain insight from experts. The contracts can in turn serve as input to the object design, as they describe changes that are likely required in the software objects or database.

Example

 * Operation: Name of operation, and parameters.
 * Cross Reference: Use cases this operation can occur within.
 * Preconditions: Noteworthy assumptions about the state of the system or objects in the Domain Model before execution of the operation. These are non-trivial assumptions the reader should be told.
 * Postconditions: This is the most important section. The state of objects in the Domain Model after completion of the operation.


 * Operation: enterItem(itemID: ItemID, quantity: integer)
 * Cross References: Use Cases: Process Sale
 * Preconditions: There is a sale underway.
 * Postconditions:
 * 1) A SalesLineItem instance sli was created (instance creation).
 * 2) sli was associated with the surrent Sale (association formed).
 * 3) sli.quantity became quantity (attribute modification).
 * 4) sli was associated with a ProductDescription, based on itemID match (association formed).

The categorizations such as "(instance creation)" are a learning aid, not properly part of the contract.

Postconditions
The postconditions describe changes in the state of objects in the domain model. This include instances created, associations formed or broken, and attributes changed.

Postconditions are not actions to be performed during the operation, rather, they are observations about the domain model objects that are true when the operation has finished.