When we have a lot of use cases, especially sea-level use cases, it can be difficult to understand how the individual use cases interact. The use case diagram shown in Figure 4.7 is a table of contents of the use cases in Order Merchandise. While it shows actors and activities, it does not show any context to those activities. How can we show these user activities and how the individual use cases are sequenced to carry out those activities? Figure 4.8 shows an activity diagram that presents the use case Order Merchandise as a sequence of single-interaction use cases. Figure 4.8. Activity Diagram for the Use Case Order BooksEach oval is an activity, corresponding to a use case. The arrows between the activities show sequence: Start a New Order, then Add Item to Order. Arrows that loop back indicate an iteration, so the example allows for several items to be added. To help visualize activities that encompass use cases initiated by several distinct actors, divide the activity diagram into swimlanes. These divide the activities into individual columns by actor. An activity diagram can also show alternatives and decision logic. For example, the Customer may add more items or check out; the credit card company can either approve or decline the charge. Concurrency and synchronization can also be shown to place use cases in context. If several use cases can all be executed concurrently, use a fork to show where the concurrency begins and a join to show where the concurrent paths are re-synchronized. |