13.8. Guidelines: Contracts

Apply the following advice to create contracts:

To make contracts:

1.
Identify system operations from the SSDs.
2.
For system operations that are complex and perhaps subtle in their results, or which are not clear in the use case, construct a contract.
3.
To describe the postconditions, use the following categories:
  • instance creation and deletion

  • attribute modification

  • associations formed and broken

Advice on Writing Contracts

  • State the postconditions in a declarative, passive past tense form (was …) to emphasize the declaration of a state change rather than a design of how it is going to be achieved. For example:

    • (better) A SalesLineItem was created.

    • (worse) Create a SalesLineItem.

  • Remember to establish a memory between ...

Get Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and the Unified Process, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.