Executable UML: A Foundation for Model-Driven Architecture
Systems respond to external signals by carrying out some desired activity, often with varying outcomes depending upon the system's state. Each desired activity is a functional requirement, such as:
Use cases are a tool for organizing system requirements by understanding the interactions between the actors that make a request and the responses, or activities, made by the system. (These terms were first defined in [1].) 4.1.1 Actors
Definition: An actor is a role played by an external entity that requires something from the system in one or more interactions with the system. Roles played by people are the most obvious actors. In an online bookstore we have obvious roles such as: Organizations can also be actors:
Sometimes there may be situations where different actors may all request the same activity. For example, a delivery person delivers the order to the customer, but the dispatcher notifies the system. Who is the actor? The delivery person? The dispatcher? In this case, an effective strategy is to abstract away the mechanism and focus on the eventual source of the request, in terms of the role, in this case the customer. People and organizations are not the only actors. Use cases may be initiated by the expiration of a delay, or the arrival of an external signal that signals some absolute time. For example, the store requires that an order more than five days old that hasn't been checked out be automatically canceled and deleted from the system. In this example, no active user of the system is initiating the use case. Instead, a timer is set when the order is first made and canceled when the order is checked out. The timer is the actor and the expiration of the timer initiates the use case. 4.1.2 Use Cases
Definition: A use case specifies an interaction between the system and one or more actors together with the activities performed by the system. For example, in the online bookstore, customers start orders, add and remove items, change the quantity of items, and cancel orders. We may represent this graphically, using a stick figure for an actor and an oval for a use case, as shown in Figure 4.1. Figure 4.1. Use Case Diagram for the Online BookstoreWe name an activity so it does not include the name of the actor. Hence, we prefer Order Merchandise over Customer Orders New Merchandise. This naming scheme has the advantages of reducing redundancy (why state the actor twice?) and flexibility (other actors can start a new order). Consequently, any time a single use case is referred to by more than one actor, the activity's behavior is the same regardless of the actor. If that is not the case, we have distinct activities that must also be named differently. So one oval pointed to by two actors is different from two ovals, as in Figure 4.2. Figure 4.2. Different Use Cases for Different ActorsWe have also found it useful to represent the use case diagram as a table, as shown in Figure 4.3 Figure 4.3. Use Cases Listed as a Table4.1.3 External Signals
A line to a use case shows the initiating actor. The actor does something or requests something from the system and so is seen as a source of an external signal that initiates the activity. The system itself receives the external signal to inform it of the request to carry out the activity. External signals often carry data, say, the book number and quantity to restock the product. These data values act as parameters, as shown in Figure 4.4. Figure 4.4. External Signals with Their Parameters
The way in which the system becomes aware of the external signal is not relevant to the essential requirements of the application, so it should not appear as part of the use case. This formulation effectively separates the interfacing technology, the user interface, from the problem at hand. Whatever you do, do not model every field on some screen as a separate use case. Exactly how those data values were accumulated is not relevant. Likewise, if a particular UI design requires stepping through multiple windows and menus, do not treat each of these elements as its own use case. Instead, at some point, a group of related data items are ready and confirmed by the actor. Treat the entire unit as a single external signal that starts the activity. It is helpful to note any proposed interfacing solutions as part of a description of the external signal, but these possible solutions should not be allowed to obscure the essentials of the use case. |