60 likes | 299 Views
Chapter 11. Operation Contracts. Operation Contracts. A tool of requirements analysis (OOA) that describes in great detail the changes required by a system operation. Analysis of what must happen, not how . Stated in terms of postconditions :
E N D
Chapter 11 Operation Contracts
Operation Contracts • A tool of requirements analysis (OOA) that describes in great detail the changes required by a system operation. • Analysis of what must happen, not how. • Stated in terms of postconditions: • Observations about the domain model objects that are true when the operation has finished. • Describe state changes: • Instance creation and deletion. • Attribute change of value. • Associations formed and broken.
Sections of a Contract • Operation: • Name of operation and parameters. • Cross References: • Use cases this operation can occur within. • Preconditions: • Noteworthy assumptions about state of system before execution of operation. • Postconditions: • The state of objects in the Domain Model after completion of the operation.
An Example Contract Operation: enterItem( itemID: ItemID, quantity: integer ) Cross References: Use Cases: Process Sale Preconditions: There is a sale underway. Postconditions: • A SalesLineItem instance sli was created. • sli was associated with the current Sale. • sli.quantity became quantity. • sli was associated with a ProductDescription, based on itemID match.
When to use Contracts • High-complexity domains. • For system operations that are complex and perhaps subtle in their results. • Don’t clutter up a use case with fine-grained details. • DON’T write contracts if developers can easily infer what to do from the use case.