11.5. Example:
enterItem PostconditionsThe following section dissects the motivation for the postconditions of the enterItem system operation.
Instance Creation and Deletion
After the itemID and quantity of an item have been entered, what new object should have been created? A SalesLineItem . Thus:
- A SalesLineItem instance sli was created (instance creation).
Note the naming of the instance. This name will simplify references to the new instance in other post-condition statements.
Attribute Modification
After the itemID and quantity of an item have been entered by the cashier, what attributes of new or existing objects should have been modified? The quantity of the SalesLineItem should have become equal to the quantity parameter. Thus:
- sli.quantity became quantity (attribute modification).
Associations Formed and Broken
After the itemID and quantity of an item have been entered by the cashier, what associations between new or existing objects should have been formed or broken? The new SalesLineItem should have been related to its Sale , and related to its ProductDescription . Thus:
- sli was associated with the current Sale (association formed).
- sli was associated with a ProductDescription , based on itemID match (association formed).
Note the informal indication that it forms a relationship with a ProductDescription the one whose itemID matches the parameter. More fancy and formal language approaches are possible, such as using the Object Constraint Language (OCL). Recommendation: Keep it plain and simple.