4.4 Formalizing Use Cases


The initial description of a use case is text. We can formalize the definition of a use case in terms of preconditions and postconditions. Preconditions state what must be true for the use case to execute. Postconditions state what must be true when the use case has completed.

The formulation of a use case in terms of pre- and postconditions is both precise and concise, in no way presupposes a particular design, and avoids the pitfall of specifying the use case in an overly procedural form.

4.4.1 Preconditions

Each use case may have zero or more preconditions.

Definition: A use case precondition denotes a relevant, verifiable property of the system that is required to be true before the use case is performed.

To help identify preconditions, examine the use case's parameters. For example, Add Item to Order has the parameters Order Number, Book Number, and Quantity. This raises questions about each of these items. What must be so? In the case of Add Item to Order, then, we expect the following to be true:

  • There is an unexpired Order not yet checked out.

  • The item selected is a book carried by the store.

  • The quantity selected is a number greater than zero and less than stock on hand.

4.4.2 Postconditions

Each use case has at least one postcondition.

Definition: A use case postcondition represents what must be true when the use case has completed.

After Add Item to Order completes successfully, we expect the following to be true:

  • The order is no longer empty.

  • The order is not checked out.

  • The book is included in the order with the given quantity.

  • The total value of the order is increased by the unit price of the book times the quantity selected.

We can write a use case in terms of preconditions and postconditions, as seen in Figure 4.9.

Figure 4.9. Preconditions and Postconditions for Add Item to Order

graphics/04fig09.gif

4.4.3 Linked Use Cases

One use case's postcondition is often another's precondition. This is especially true when we have sequences of use cases characterized as activities, as you can see in Figure 4.10.

Figure 4.10. Connecting Preconditions and Postconditions

graphics/04fig10.gif



Executable UML. A Foundation for Model-Driven Architecture
Executable UML: A Foundation for Model-Driven Architecture
ISBN: 0201748045
EAN: 2147483647
Year: 2001
Pages: 161

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net