Mutlaka Bakk
Mutlaka Bakk
Mutlaka Bakk
Chapter 3 - Use case Modeling and Analysis Overview Requirement elicitation Use Case Modeling techniques Use Case Modeling examples Use Case Analysis Techniques Use Case Modeling and Analysis Process Tricks & Tips in using Use Case Analysis Use Case Modeling and Analysis with VP-UML Summary Exercise 73 74 75 80 81 94 109 113 147 147
Chapter
3
Use Case Modeling and Analysis
Overview
The software development process is time-consuming and labor-intensive. The seemingly straightforward, but deceptively difficult, part of this process is to clearly understand and specify the requirements that an application must satisfy. Because of the reiterative nature of the software development process, mistakes made in early stages but are only identified at a much later stage will result in costly reworks and delays. Use case modeling is an increasingly popular approach for identifying and defining requirements for all kinds of software applications as it is a formalized process for capturing system scenarios. While use case modeling is often associated with and used extensively in projects that utilize the object-oriented approach, it can also be applied to any project regardless of the underlying implementation technology or development approach. This chapter provides a thorough presentation of the use case modeling approach to software requirements elicitation, including practical, proven techniques that can be immediately applied to software development projects.
73
74 Object-oriented Technology
document use cases incorporate use case modeling into the project life cycle
Requirements Elicitation
A requirement describes a condition or capability to which a system must conform. Requirements are supposed to represent what the system should do as opposed to how the system should be built. They are either derived directly from user needs or stated in a contract, standard, specification or other formally imposed document. Requirements elicitation is the process of defining your system. It involves obtaining a clear understanding of the problem space, such as business opportunities, user needs or the marketing environment, and then defining an application or system that solves that problem.
As mentioned before, the major difficulty in defining system requirements is that very often it is not known what the users actually want. A good use case must represent the point of view of the people who will use or interact with the system; in other words, use cases must describe the behaviors expected of a system from a users perspective. A complete set of use cases specifies all the possible ways the system will behave, and therefore defines all the requirements (behaviors) of the system, binding the scope of the system. A use case should be considered as a unit of requirement definition or simply a user goal, such as deposit money or check balance in an automatic teller machine (ATM) system. In the requirements elicitation process, it is important to correctly identify a set of use cases to discover the real user requirements of the system being developed.
76 Object-oriented Technology
In addition, a use case diagram may consist of a system boundary. Actors Actors are the entities that interact with the system. They include everything that needs to exchange information with the system. Actors are, therefore, the entities external to the system being designed. An actor may be: people computer hardware and devices external systems
An actor represents a role that a user can play, but not a specific user. An actor, therefore, represents a group of users taking on a particular role. For example, both John and Peter may be consultants. At the same time, John may also be a project manager in the company. Thus, the same person may be an instance of more than one actor, and conversely, several people can play the same role of an actor. The common way to identify use cases is to interview the users who will directly operate the system. This process can help design a system which suits their needs. However, other stakeholders of the system, such as the customers and the policy makers of the business process, may be missed out in the vital stages of development. Consequently, the system may not satisfy the needs of all stakeholders. For example, consider a general mail order business consisting of at least three groups of stakeholders: the customer, the staff member who operates the system and the manager of the company. These stakeholders may have different requirements of the system: The customer requires that the services provided by the company minimize his time and effort The manager wants to maximize the profits of the company The staff member hopes to minimize the stock level, bad debts, etc
Obviously, the stakeholders requirements may sometimes contradict. The development team should hold meetings with all stakeholders to determine all requirements as well as to resolve those that contradict. Representing Actors The stick figure is most widely used to represent actors, and it is used even when the actors are not human. Another way to represent an actor in the UML notation is a class icon with the <<actor>> stereotype placed above the class name inside the upper compartment, as shown in Figure 3.1.
Types of Actors Actors can be divided into two common types: primary actors and secondary actors. Primary actors are the main users or entities for which the system is designed, deriving benefits form it directly. The following are some key characteristics of primary actors: Primary actors are completely outside the system and drive the system requirements Primary actors use the system to achieve an observable user goal
As such, the designer has less flexibility in specifying the roles of the primary actors in order to satisfy the requirements of the stakeholders. Secondary actors are users or entities that supervise, operate and manage the system. They play a supporting role to facilitate the primary actors to achieve their goals. The following are some key characteristics of secondary actors: Secondary actors often appear to be more inside the system than outside Secondary actors are usually allocated many system requirements that are not derived directly from the statement of requirements
Hence, the designer can have more freedom in specifying the roles of these actors. For an example of the roles played by both actors, a tax return can be submitted directly by a taxpayer (the primary actor) either through the Internet or by post. If it is the latter, a data entry operator will enter the data contained in the tax return form to the system. The data entry operator can be viewed as the secondary actor, as he/she helps the taxpayer process the tax return form. There is a less commonly used group of actors called generalization actors. Generalization is a key concept in object-orientation and object-oriented
78 Object-oriented Technology
modeling, allowing models to be simplified and made more expressive. The fact that actors are classes means that actors can be generalized. Through the generalization process, similarities between different actors can be identified. The UML icon for generalization is a small hollow arrowhead pointing at the superclass of the actor. For instance, a generic actor, such as System Designer, can be inherited by other actors, such as System Analyst and Project Manager. Figure 3.2 shows that the inheriting actors (System Analyst and Project Manager) also inherit the Use Cases associated with the inherited Actor (System Designer).
Figure 3.2. Generalization of actors
System Designer
System Analyst
Project Manager
Actors versus Roles Cockburn (2001) suggests that the word role should be used instead of the word actor in use case modeling the word actor could be misinterpreted leading to confusion. It may be interpreted as an individual or an official rank or a job title in an organization. None of these meanings match the required definition. In the use case model, the precise meaning of actor should be a set of roles that can be played by individuals or other external systems. For example, Peter is an order processing clerk and Raymond a sales manager. Both of them can process an order. Hence, Peter and Raymond can be actors of the Process Order use case. We might say that a sales manager can perform any use case an order processing clerk can. More precisely, Order Handler is defined as the role of processing an order. As such, both Peter and Raymond can play the role
Order Handler. Hence, the same person can play different roles at different times, and staff members with the same job title may play different roles to suit the needs of the business requirements. Use Cases A use case describes a sequence of actions a system performs to yield an observable result or value to a particular actor. In other words, use cases are abstractions of dialog between the actors and the system; they describe potential interactions without going into the details of each scenario. In the UML notation, a use case is represented by an oval with a label describing the actors goal. A use case is connected to one or more actors using communication links represented by straight lines. For example, in interacting with an ATM system, one of the customer goals is to withdraw money from his/ her account. The representation of this requirement in UML is shown in Figure 3.3.
Figure 3.3. Actor, use case and communication link
Withdraw Cash
Customer
A good use case should describe a sequence of transactions performed by a system that produces a measurable result (goal) for a particular actor describe the behavior expected of a system from a users perspective enable the system analyst to understand and model a system from a highlevel business viewpoint represent the interfaces that a system makes visible to the external entities and the inter-relationships between the actors and the system
System Boundaries System boundaries define the scope of the system being developed and are represented by rectangles in the UML notation. All use cases should reside within the system boundary. The actors are placed outside of the system boundary and all the use cases collectively make up the total requirements of the system.
80 Object-oriented Technology
Deposit Money
Customer
Check Balance
System boundary
Communication
Make Booking
Individual Customer
82 Object-oriented Technology
Communicating with clients. Their notational simplicity makes use case diagrams a mechanism for early discussions with potential users and domain experts. Generating test cases. The collection of scenarios for a use case may also provide a suite of test cases and a starting point from which the prototype user interface is shaped. A scenario captures a specific execution of a use case. In other words, a use case is a generalized description or template of a sequence of transactions, while a scenario is an instance of the use case which describes how the use case will be executed in a specific situation.
UseCaseName
Actor
ActorName System boundary The boundary between the physical system and the actors who interact with the physical system. ApplicationName
Association
The participation of an actor in a use case, i.e. an instance of an actor and instances of a use case communicating with each other. A taxonomic relationship between a general use case and a more specific use case. The arrow head points to the general use case.
Generalization
Chapter 3: Use Case Modeling and Analysis 83 Table 3.1. Construct Extend (Contd) Syntax
Description A relationship between an extension use case and a base use case, specifying how the behavior of the extension use case can be inserted into the behavior defined for the base use case. The arrow head points to the base use case. A relationship between a base use case and an inclusion use case, specifying how the behavior for the inclusion use case is inserted into the behavior defined for the base use case. The arrow head points to the inclusion use case.
<<extend>>
Include
<<include>>
84 Object-oriented Technology
<<extend>> are stereotypes for use case relationships. Each of these relationships is explained in detail below.
Figure 3.6. Two use cases with a common behavior
Use case: Withdraw Money Flow of events: 1. The user inserts an ATM card. The system prompts the user to enter a password. The user enters the password. The system validates the user password.
Use case: Deposit Money Flow of events: 1. The user inserts an ATM card. The system prompts the user to enter a password. The user enters the password. The system validates the user password.
2.
2.
Common behavior
Figure 3.7.
Use case: Login Account Flow of events: 1. 2. The user inserts an ATM card. The system prompts the user to enter a password. The user enters the password. The system validates the user password.
Login Account
Deposit Money
<<include>>
The <<include>> Relationship <<include>> relationships are used when two or more use cases share some common portion in a flow of events. This common portion is then grouped and extracted to form an inclusion use case to be shared among two or more use cases. For example, most use cases in the ATM system example, such as Withdraw Money, Deposit Money or Check Balance, all share the inclusion use case Login Account (see Figure 3.8). The <<extend>> Relationship <<extend>> relationships are used when two use cases are similar, but one does a bit more than the other. For example, you may have a use case that captures the typical case (the base use case) and use extensions to describe variations. A base use case may, therefore, conditionally invoke an alternative use case. In other words, the extension use case adds an extra behavior to the base use case. For example, Withdraw Money has an optional behavior which handles withdrawal of an excess amount. We capture this optional behavior in an <<extend>> use case (see Figure 3.9).
Figure 3.9. An <<extend>> use case
User
86 Object-oriented Technology
The Generalization Relationship A child use case can inherit the behaviors, relationships and communication links of a parent use case. In other words, it is valid to put the child use case wherever a parent use case appears. The relationship between the child use case and the parent use case is the generalization relationship. For example, suppose the ATM system can be used to pay bills. Pay Bill has two child use cases: Pay Credit Card Bill and Pay Utility Bill (see Figure 3.10).
Figure 3.10. A generalization relationship Pay Credit Card Bill
Pay Bill
Customer
Base Use Case versus Abstract Use Case Once a set of use cases of the system has been identified, common behaviors may be found. By extracting their common behaviors, we can form a base case (concrete use case) and an abstract use case. The former is basically the main use case which may be instantiated directly by an actor as it can achieve an observable user goal by itself. The latter can only be instantiated by a base use case as it only contains a portion of the common behaviors shared among two or more use cases. Therefore, it is not a complete goal from the users perspective. For example, in Figure 3.8, a use case such as Login Account is not a use case but an abstract use case (or an <<include>> use case), because logging into the system does not achieve a complete user goal. A goal is not achieved if a user goes to an ATM, logs in to the system and then leaves without making a transaction. Typical operations a user may want to carry out through an ATM could be Check Balance, Request Check Book or Deposit Money, etc. A use case may also exhibit several scenarios: the normal scenario and possible several alternative scenarios. Similarly, the base use case can be used to represent the normal scenario, while abstract use cases describe the alternative scenarios.
Figure 3.11 shows a part of a use case model for an ATM system. Withdraw Money is the base use case as it is the normal scenario for the user to successfully log in to the system, specify the transaction type and input a valid amount for withdrawal. Process Excess Amount is an abstract use case (or an <<extend>> use case) as the user may have enough money in his bank account for the amount that he wishes to withdraw.
Figure 3.11. Extension point in the base use case Withdraw Money <<extend>> Extension points Excess Amount User
Only base use cases may be invoked directly by an actor, while abstract use cases can only be instantiated by a base use case. The instantiation of an abstract use case must return to the calling use case (the base use case) at the exact point from where the call was made. Abstract use cases are composed of portions extracted from other use cases. Abstract use cases are similar to subroutine calls, where the base use case likens to a main program. Thus, the base use case exhibits a complete behavior to achieve a user goal, while an abstract use case exhibits a partial behavior of a base use case. In the UML notation, the relationship between a base use case and an abstract use case is represented by an <<include>> or <<extend>> stereotype. Figure 3.12 illustrates the base use case, Withdraw Money with an optional behavior represented by the abstract use case, Process Excess Amount. In the figure, the base use case also includes the extension point (Excess Amount) where a call to the abstract use case Process Excess Amount can be made. Notes: Normally similar behaviors of use cases can only be identified and extracted after they have been completely defined. A designer can then extract those parts with a similar logic into separate abstract use cases that are used by other use cases. Abstract use cases are refinements that are of more interest to the designer than the user. It is important to note that structuring use cases is unlike developing a flow chart (deterministic sequence of flow) or a data flow diagram (functional decomposition) as it focuses on user goals. Thus, Login Account should not be
88 Object-oriented Technology
considered as a base use case. This is a common mistake that some designers make because they incorrectly assume that the user needs to log in to the system first before he/she can perform tasks such as Withdraw Money or Deposit Money. Consequently, they wrongly treat Login Account as a base use case which instantiates Withdraw Money and Deposit Money as abstract use cases. In fact, the two base use cases should be Withdraw Money and Deposit Money as they share a common block in the flow of events (the Login Account inclusion use case).
Figure 3.12. Use case diagram showing <<include>> and <<extend>> relationships ATM System <<extend>> Process Excess Amount
Withdraw Money
<<include>>
User
Deposit Money
<<include>>
Login Account
Transfer Money
<<include>>
Figure 3.13 conceptualizes that a use case can be elaborated by a use case description in a more detailed form in that a use case description is explained and elaborated through scenarios (a sequence of actions). Each of these scenarios is simply an instance of the use case. In other words, a use case instance is only a particular example of a use case (a particular system service). As defined by Booch, a use case not only consists of a normal scenario, but possibly its variant scenarios. In such cases, they need to be represented in <<extend>> use cases, where each should be elaborated by a separate use case description.
Figure 3.13. Use cases and their scenarios
ATM System Withdraw Money Instance scenario (successfully withdraws $250.00) Withdraw Money <<include>> <<extend>> Login Account
Check Balance
For example, the ATM system may provide the Withdraw Money service to customers in many different scenarios. A typical scenario may involve the customer withdrawing money from the machine from which he/she has requested the transaction. In another scenario, the system may report that the password keyed in by the customer is incorrect, requiring the customer to re-enter the password. Developing Base Use Case Descriptions As a use case diagram is a communication aid between the software designer(s) and the end user(s), it is important that descriptions are free of computing jargons and unfamiliar terminologies. Plain, simple language that the user can relate or understand should be used. Computer or technical terms that are related to the implementation of the system should be avoided. Indeed, when constructing a use case diagram, designers should not be thinking about computers at all; they should be focusing only on the users and system services.
90 Object-oriented Technology
Because the use case model has to be understood by both the users and the software developer, the base use case descriptions are written in natural language. However, most experts recommend a systematic approach by using a certain template so that useful information about the use case is not overlooked. The brief descriptions in the use case template are expanded to include details of the interactions between the actors and the use cases.
Name of the use case ID of the use case The name of the generalized use case to which this use case belongs The name of the actor(s) who participate in the use case A description showing how this use case adds value to the organization; that is, what is the purpose or role of this use case in enabling the actors to do their job The conditions that must be satisfied before this use case can be invoked The conditions that will be established as a result of invoking this use case The development priority of this use case A step-by-step description of the interactions between the actor(s) and the system, and the functions that must be performed in the specified sequence to achieve a user goal
Preconditions
Post-conditions
Chapter 3: Use Case Modeling and Analysis 91 Table 3.2. Alternative flows and exceptions Non-behavioral requirements (Contd)
Major alternatives or exceptions that may occur in the flow of events The non-functional requirements of the system such as hardware and software platform requirements, performance, security, etc. All the assumptions made about the use case All outstanding issues regarding the use case Reference materials relevant to the use case
The components of a use case template written as high-level descriptions in natural language have to be agreed by both the client and the development team. Bear in mind that a use case is a high-level communication tool for both stakeholders. The following provides an explanation of each item in the template shown in Table 3.2. Use case name describes the goal of the actor. Typically, it is in a verb noun phrase or verb noun format, e.g. Withdraw Money. Use case ID is a unique identifier of the use case. It usually has a format like UC number, e.g. UC100. The prefix generally represents the type of UML element and the number should be allocated systematically for easy reference. Super use case. This field can be blank. If the use case inherits a parent use case, this entry is the name of the parent use case. Actor(s). All the actor(s) participating in the execution of the use case are listed, such as people, systems, etc. Brief description. A concise description is used to define the scope of the use case and the observable value to the actor. Preconditions and post-conditions. Preconditions specify some constraints that must be satisfied before the use case can be invoked, while postconditions serve to ensure that the use case has performed the task properly after invocation. Both pre- and post-conditions provide important hints for system test (at the use case level) in the subsequent software development stage. Let us consider the ATM example again. The Withdraw Money use case is a normal scenario and its preconditions may be the following: a valid ATM account, a positive balance, the maximum daily
92 Object-oriented Technology
accumulative withdrawal amount is $2,000. The post-condition may be that after processing the withdrawal transaction, the account balance must remain positive and the daily accumulative withdrawal amount must not exceed $2,000. Well-specified pre- and post-condition elements of the use case description can significantly reduce the complexity of the use case. They can also be used as black-box test cases. Furthermore, the contents of the pre- and post-conditions can be used for deriving alternative scenarios for that use case. Priority. The priority in the use case template serves to indicate the priority ranking in the development schedule from the view of the development team. We usually assign a high ranking to use cases that are architecturally significant. Similarly, a high priority ranking should also be assigned to those use cases which are thought to be more difficult or have many unknown factors or risks associated with them. All high priority use cases will be analyzed and developed first in the development schedule. If a use case covers a wide area of the system in terms of hardware nodes or software subsystems, this use case will be considered architecturally significant. For example, the Withdraw Money use case will cover a wide area of the ATM system: card authentication, account login, account selection, amount input, etc. In terms of hardware nodes, its execution involves the collaboration of the ATM machine, the central bank computer and the individual banks computers. On the other hand, the Check Balance use case will definitely be less significant by comparison with the Withdraw Money use case. Flow of events. The flow of events captures the external observable behaviors of the use case and focuses on describing the interactions between the user and the system when the use case is invoked. This component of the use case template describes the main flow of interactions. Alternative flows and exception handling are also captured in the Alternative Flows and Exceptions section of the template. Important system actions that lead to the post-conditions of the use case are also captured. Other unimportant internal logic of the system should be ignored since the purpose here is to define the specifications of the system. Alternative flows and exceptions describe the execution of the use case under exceptions that are not covered in the flow of events. Non-behavioral requirements describe the requirements other than functional or behavioral requirements: performance, user interface, etc.
Assumptions about the use case should be recorded. For example, the password is numeric only, with not more than ten digits. Issues. All outstanding issues related to the use case need to be resolved. For example, should the user interface be customizable for customers of different banks? Source. This field includes references and materials used in developing the use case such as memos, minutes of meetings, etc.
94 Object-oriented Technology
The priority ranking of a use case is determined by taking the above factors into account. Usually, a fuzzy scheme of highmediumlow would be used to rank use cases. If a more precise ranking is required, each use case can be assigned with a score for each factor and the total score will be used for ranking. For better precision in ranking, it is also possible to apply weightings to the factors in calculating the total score.
System1 Package1
Use model ATM System Use case analysis Customer Withdraw Money Deposit Money Check Balance Problem statement
Package2
Structuring use cases Withdraw Money <<include>> <<extend>> Login Account Process Excess Limit
Use case description Brief description Flow of events Instance scenario (successfully withdraws $250.00)
Textual analysis
Test cases
96 Object-oriented Technology
Creating an initial use case diagram Describing briefly the use cases (with initial descriptions) Identifying/Refining candidate business (domain) classes using textual analysis
Refining the use case model includes the following steps: Developing base use case descriptions Iteratively elaborating on the base use cases descriptions and determining the <<extend>>, <<include>> and generalization relationships Developing instance scenarios Prioritizing use cases
The above steps need not be performed in a sequential order. Some steps may be performed in parallel, while others may be revisited after another step has been performed. For example, after identifying the candidate classes, the brief use case description may require revision. In addition, different use cases may be developed at a different pace. Some use cases may be fully developed, while others may just have their title designations which will be further elaborated at a later stage. Hence, the reader should treat these steps as a checklist of items to be performed to complete the use case model.
Use Case Modeling: Mail Order Case Study Step 1: Develop Problem Statement
In order to improve the operational efficiency of a mail order company, the chief executive officer is interested in computerizing the companys business process. The major business activities of the company can be briefly described as follows: A customer registers as a member by filling in the membership form and mailing it to the company. A member who has not been active (no transactions made) for a period of one year will be removed from the membership list and he/she needs to re-apply for the reinstatement of the lapsed membership. A member should inform the company of any change in personal details such as home address, telephone numbers, etc. A member can place an order by filling out a sales order form and faxing it to the company or by phoning the Customer Service Assistant with the order details. The Customer Service Assistant first checks for the validity of membership and enters the sales order information into the system. The Order Processing Clerk checks the availability of the ordered items. If they are available, he/she holds them for the order. When all the ordered items are available, he/she will schedule their delivery. The Inventory Control Clerk controls and maintains an appropriate level of stock and is also responsible for acquiring new items. If there is a problem with an order, the member will phone the Customer Service Assistant, who will then take appropriate action to follow up the particular sales order. Members may return defective goods within 30 days and get their money back. The system will record the name of the staff member who handled the transaction for future follow up action.
98 Object-oriented Technology
A short paragraph should then be written to describe each of the actors. Table 3.3 shows the specification of the Order Processing Clerk.
Table 3.3. Actor Name Description Specification of Order Processing Clerk actor
Order Processing Clerk The Order Processing Clerk is responsible for processing sales orders, submitting re-order requests, requesting necessary deposits from members and scheduling the delivery of the goods to the member.
Guidelines for Identifying Use Cases Finding use cases is an iterative process. This process normally starts with interviewing the users (actors) who directly or indirectly interact with the system. Typically, it starts from bottom up, involving the customer describing scenarios from their business activities. Each of these descriptions is a possible use case. These potential use cases can then be elaborated, modified, broken into smaller use cases or integrated into larger ones. An important fact to remember is that people are generally not very forthcoming, and extracting useful information from the users is a skill that takes years of experience. The following questions may be useful in collecting information from users: What are the main tasks carried out by each actor? What data are manipulated and processed by the system? What problems is the system going to solve? What goals does an actor want to achieve using the system? What are the major problems with the current system and how can the proposed system simplify the work of the user?
Guidelines for Naming Use Cases The name of a use case consists of a verb and a noun or noun phrase in the following format: verb noun or verb noun phrase
The use case name describes an operation which achieves an observable user goal. For example, Place Order is a use case in an Order Process System, and Withdraw Money is also a use case for an ATM system (see Figure 3.15). They are in the verb noun format.
Figure 3.15. Place Order Examples of use cases Withdraw Money
As use case models serve as a communication tool between end users and system designers, it is often preferable to use high-level and non-technical naming terminology understood by the layman. Some designers prefer to use verb noun phase for naming their use cases. For example, you may prefer to name a use case as select a suitable candidate from the HR database instead of Select Candidate for a human resources information system.
By examining the responsibilities of the actors of the Mail Order System, the following use cases are identified: Check Order Status Place Order Handle Goods Return Update Membership Record Archive Membership Register New Member Process Order Schedule Delivery Order Goods Receive Goods Deliver Goods The complete initial use case model is shown in Figure 3.16.
Place Order Schedule Delivery Handle Goods Return Order Processing Clerk
Membership
Update Membership Record Customer Service Assistant
Inventory Control
Order Goods
Archive Membership
Deliver Goods
Chapter 3: Use Case Modeling and Analysis Table 3.4. Initial use case description of the Schedule Delivery use case Use Case Use Case ID Actor Description Schedule Delivery UC-300 Order Processing Clerk
101
The Order Processing Clerk selects an order from the list of filled sales orders. The system displays the sales order details, together with the members telephone number and address. The Order Processing Clerk enters the delivery date and time after talking with the member over the phone. The system records the delivery date and time in a dispatch request to the delivery team.
Table 3.5. Brief description of the Check Order Status use case Use Case Use Case ID Actor Description Check Order Status UC-400 Customer Service Assistant The Customer Service Assistant enters the ID of the member. The Customer Service Assistant selects a sales order of the member. The system displays the status of the sales order.
Identify/Refine Candidate Business (Domain) Classes Having prepared a brief description for each of the use cases, try to identify the classes of the system. The identified classes will then be used as part of the vocabulary for writing the expanded use case descriptions. It is important to note that identification of objects and classes is a continuous process throughout the whole system development life cycle; the class model will be iteratively refined in each step of the life cycle. During the use case analysis process, classes can be identified by performing a textual analysis on the brief use case descriptions. The nouns and noun phrases in the use case descriptions are highlighted and evaluated for
possible inclusion as a candidate class. The result of the analysis is a set of candidate classes with their descriptions. An initial class diagram is drawn to show the static relationships between the classes. If a domain analysis has been performed to develop a domain class model, the results of this step will be combined with the domain class model to produce the initial class model. This was elaborated on in the previous chapter.
Schedule Delivery UC-300 Order Processing Clerk The Order Processing Clerk selects an order from the list of filled sales orders. The system displays the sales order details, togehter with the members telephone number and address. The Order Processing Clerk enters the delivery date and time after talking with the member over the phone. The system records the delivery date and time in a dispatch request to the delivery team.
Note: Recall that a use case model often consists of several use cases. Each of the use cases has its own corresponding use case description, including its brief description and the flow of events, providing more details. As progress is made in the development of the project, more and more use cases will be developed according to the use case schedule. Iteratively and incrementally refine and enrich the initial class model (Figure 3.17) by performing the textual analysis for each of the use cases that have been developed.
103
placed by
placed by
Order
Goods supplied by
Purchase Order
Goods Return
Order Line
Supplier
Goods Receive
Expand Initial Use Case Model The initial use case model is expanded incrementally in subsequent phases of the system development life cycle. In each phase, some use cases are selected and analyzed to produce detailed specifications of the necessary behavioral and functional requirements. Common behaviors and alternative behaviors of use cases are identified when the use cases are expanded and analyzed. These behaviors are extracted to become inclusion, extension and generalization use cases. These, in turn, help to make the use case model easier to maintain. The classes identified in the analysis of the use cases are used to update and refine the class model.
104 Object-oriented Technology Table 3.7. Description for the Place Order use case Use case name Use case ID Super Use Case Place Order UC-100 The name of the generalized use case to which this use case belongs. Customer Service Assistant A Customer Service Assistant places an order and then submits it for processing. The member must have registered with the system. The Customers order will be directed to the order process department for processing. 1. The Customer Service Assistant finds the members record by entering the members ID or name. The system displays a list of members that match the information entered by the Customer Service Assistant. The Customer Service Assistant selects the required member record. The system displays the details of the member. The Customer Service Assistant selects Place Order. A new order form and order ID are then generated and displayed. The Customer Service Assistant selects items from the catalog and adds them to the order. The Customer Service Assistant submits the order for processing. The system records the order and forwards it to the Order Processing Clerk.
Preconditions Post-conditions
Flow of events
2.
3.
4. 5.
At any time the Customer Service Assistant can decide to suspend the ordering process and come back to it later, or to cancel the order. High The system should be able to handle 20,000 new orders per day.
Is there any limit on the amount of an order? User Interview Memo 21, 8/9/01
105
<<include>> Membership Inventory Control Order Goods Find Member Record <<include>> Register New Member Deliver Goods
Archive Membership
Receive Goods
The revised descriptions of the Place Order and Find Member Record use cases are shown in Tables 3.8 and 3.9 respectively.
106 Object-oriented Technology Table 3.8. Revised description of the Place Order use case Use case name Use case ID Super Use Case Actor(s) Brief description Customer Service Assistant A Customer Service Assistant places an order and then submits it for processing. The member must have registered with the system. The Customers order will be directed to the order processing department for processing. 1. 2. Include (Find Member Record). The Customer Service Assistant selects Place Order. A new order form and order ID are then generated and displayed. The Customer Service Assistant selects items from the catalog and adds them to the order. The Customer Service Assistant submits the order for processing. The system records the order and forwards it to the Order Processing Clerk. Place Order UC-100
Preconditions Post-conditions
Flow of events
3. 4.
At any time the Customer Service Assistant can decide to suspend the ordering process and come back to it later, or decide to cancel the order. High The system should be able to handle 20,000 new orders per day.
Is there any limit on the amount of an order? User Interview Memo 21, 8/9/01
Chapter 3: Use Case Modeling and Analysis Table 3.9. Description of the Find Member Record use case Use case name Use case ID Brief description Post-conditions Flow of events Find Member Record UC-10 A member record is requested. A membership record is returned. 1.
107
2.
The Customer Service Assistant finds the member record by entering the members ID or name. The system displays a list of members that match the information entered by the Customer Service Assistant. The Customer Service Assistant selects the required member record. The system then displays the details of that member.
Develop Instance Scenarios A use case specifies all possible ways of using a system functionality to achieve a user goal. Sometimes, it is necessary to write some examples (instance scenarios) to illustrate the execution of a complex use case. Instance scenarios are easier for the user to understand, and they are very useful for clarifying any ambiguity in the use case description. The instance scenarios can also serve as test cases for system testing. A sample instance scenario of the Place Order use case is shown in Table 3.10.
Table 3.10. Instance Scenario of Place Order Parent use case name Parent use case ID Instance name Place order UC-100 A sales order form is received but the membership number is missing. UCIS-100-1
Instance ID
108 Object-oriented Technology Table 3.10. (Contd) Environmental conditions and assumptions Inputs Instance flow description The name (Peter Chan) and signature of the member are available in the system.
A sales order form 1. The Customer Service Assistant enters Peter Chan to find the member record. The system then displays a list of members that match the members name. The Customer Service Assistant repeatedly selects a member record. The system displays the signature of the member when a member record is selected. The Customer Service Assistant selects Place Order. A new order form and order ID are then generated and displayed. The Customer Service Assistant selects items from the catalog and adds them to the order. The Customer Service Assistant submits the order for processing. The system records the order and forwards it to the Order Processing Clerk.
2.
3.
4. 5.
Outputs
High
Place Order
Chapter 3: Use Case Modeling and Analysis Table 3.11. (Contd) High Find Member Record
109
Included as part of the Place Order use case. Ordering goods is less often than processing orders but still is one of the major business processes. Can improve the control of stock level of goods. Small impact on the system architecture. Same as above.
Medium
Order Goods
Medium
Deliver Goods
Low
Low
Deposit Money
Customer
Check Balance
Transfer Money
externally observable behaviors of an ATM system, but no customer would ever set his/her goal as inputting the password, selecting a transaction and then leaving the ATM. Furthermore, both Input Password and Select Transaction use cases do not yield an observable value to the user and, therefore, cannot achieve a user goal.
111
tools do not prohibit this), use cases are still considered as a sequence of transactions (interactions), and as such, it is not necessary to show the association with an arrow (see Figure 3.22).
Figure 3.21. Application of textual analysis in different contexts Problem statement
Customer
Textual analysis
ActorName
UseCaseName
ActorName
UseCaseName
113
The use case model can be simplified by factoring out common behaviors that are required by multiple use cases and thereafter introducing the <<include>> stereotype. If the base use case is complete and the behavior is optional, consider using the <<extend>> stereotype. The use case structuring process also helps to save time and effort in analyzing the use cases. Therefore, use case structuring should be done in an iterative and incremental manner. However, remember not to put too much effort into identifying the common behaviors and optional behaviors since this may defeat the purpose of saving time and effort. The use case structuring should be carried out when it is convenient to do so.
Apply Loan
Approve Loan
Add Customer
Bill Customer
Suspend Customer
modeling process will be illustrated with the example Mail Oder System discussed earlier using the VP-UML case tool. By walking through the process step by step, you will appreciate how easy it is to perform use case analysis and modeling. The Mail Order System example will be used to illustrate the steps in the use case analysis and modeling process. Before you begin, start the VP-UML case tool.
1.2. Type in the problem statement in the text pane. If the problem statement is already saved as a text file, open it from a file by clicking at the top left-hand corner of the text pane. 1.3. Edit the following problem statement in the text pane (see Figure 3.25).
Chapter 3: Use Case Modeling and Analysis Figure 3.24. Textual Analysis working area
115
In order to improve the operational efficiency of a mail order company, the chief executive officer is interested in computerizing the companys business process. The major business activities of the company can be briefly described as follows: A customer registers as a member by filling in the membership form and mailing it to the company. A member who has not been active (no transactions made) for a period of one year will be removed from the membership list and he/she needs to re-apply for the reinstatement of the lapsed membership. A member should inform the company of any changes of personal details such as home address, telephone numbers, etc. A member can place an order by filling out a sales order form and faxing it to the company or by phoning the Customer Service Assistant with the order details. The Customer Service Assistant first checks for the validity of membership and enters the sales order information into the system. The Order Processing Clerk checks the availability of the ordered items and holds them for the order. When all the ordered items are available, he/she will schedule their delivery. The Inventory Control Clerk controls and maintains an appropriate level of stock and is also responsible for acquiring new items. If there is a problem with an order, members will phone the Customer Service Assistant. The Customer Service Assistant will take appropriate action to follow up the sales order. Members may return defective goods within 30 days and get their money back. The system will record the name of the staff member who has initialized an updated transaction to the system.
Note: When preparing the problem statement having interviewed the key users of the system being developed, only focus on their high-level roles and goals rather than the detail workflow of the business operations associated with the system. These workflow will later be identified when you document the individual use case as flows of events in the detailed use case descriptions.
117
2.2. Now right click on the newly created candidate class in the Candidate Class Container. A pop-up menu will appear. Select the Actor option in the pop-up menu to declare the candidate class as an actor (see Figure 3.27). 2.3. Note that the icon of the candidate class in the Candidate Class Container has changed from class to actor and the type of the candidate class has also changed to Actor in the table below it (see Figure 3.28).
2.4. To enter the description of an actor, select the Class Description cell next to the actor Customer Service Assistant in the table in the bottom right corner. Type in a brief description such as the task(s) performed by the actor. Where necessary, adjust the size of the cell by dragging its boundary at the bottom of the cell edge to view the whole description (see Figure 3.29).
Chapter 3: Use Case Modeling and Analysis Figure 3.29. Entering actor description in Class Description
119
2.5. The candidate actors can be added into the model repository. Elements in the model repository can be retrieved for later use, e.g. to draw a use case diagram. To add Customer Service Assistant (candidate actor) into the model repository, right click on the Customer Service Assistant. A pop-up menu will appear. Select Create Actor Model in the pop-up menu (see Figure 3.30).
Figure 3.30. Creating an Actor in model repository
2.6. The Customer Service Assistant is now added to the Model Repository Tree. To see the newly created actor model, click on the Model tab in the Project Explorer Pane (see Figure 3.31).
Figure 3.31. Customer Service Assistant actor in Model Repository Tree
2.7. Repeat the above steps to identify and create actor models for the actors: Order Processing Clerk Inventory Control Clerk (See Figure 3.32.)
Figure 3.32. Actor models in Model Repository Tree
121
Note: When creating a candidate actor in the Candidate Class Container, it is not a model element until it appears in the Model Repository Tree. Only then can the actor be shared among various models or diagrams. To place an actor, which has been defined in the model repository, in the diagram, simply drag it from the Model Repository Tree to the desired location in the diagram area and release the mouse button. The actor will be created in the diagram and automatically inherit the name and the documentation that was previously defined. This operation can also be applied to create use cases and classes.
3.2. Right click on the Candidate Class Container. A pop-up menu will appear. Then select Add Candidate in the pop-up menu; a cascading menu will appear. Select Use Case in the cascading menu. An input dialog will appear (see Figure 3.34).
Figure 3.34. Creating a candidate use case in Candidate Class Container
3.3. An input dialog will appear. Enter Place Order in the input dialog (see Figure 3.35).
Figure 3.35. Naming a new candidate use case
123
3.4. Click OK in the input dialog. A new candidate use case is then created in the Candidate Class Container (see Figure 3.36).
Figure 3.36. A new candidate use case in Candidate Class Container
3.5. Now edit the use case brief description for the candidate use case the same way as you would edit the actor description (see Figure 3.37).
Figure 3.37. Creating a brief use case description
3.6. To add a candidate use case into the model repository, right click on the desired candidate use case in the Candidate Class Container. A pop-up menu will appear. Select Create Use Case Model (see Figure 3.38).
Figure 3.38. Adding a candidate use case to Model Repository
3.7. A new use case is added to the Model Repository Tree (see Figure 3.39).
Figure 3.39. A new use case in Model Repository Tree
125
3.8. Repeat the above steps to identify all other candidate use cases below (see Figure 3.40): Check Order Status Place Order Handle Goods Return Update Membership Record Archive Membership Register New Member Process Order Schedule Delivery Order Goods Receive Goods
Figure 3.40. Use cases in Model Repository Tree
4.2. Click on the Model tab in the Project Explorer. A list of model elements will be presented (see Figure 3.42). 4.3. Select the Place Order model from the Model Repository Tree and drag it to the desired location in the diagram pane. A use case is automatically placed in the diagram with the name Place Order (see Figure 3.43).
Chapter 3: Use Case Modeling and Analysis Figure 3.42. Models in Model Repository Tree
127
4.4. Select Customer Service Assistant from the Model Repository Tree and drag it to the desired location in the diagram pane. An actor is then placed in the diagram with the name Customer Service Assistant (see Figure 3.44).
Figure 3.44. Creating an Actor with Model Repository Tree
above the 4.5. Drag on the Association -> Use Case resource-centric icon Customer Service Assistant actor to the Place Order use case and then release the mouse button. A communication link associated between the actor and use case is created (see Figure 3.45).
Figure 3.45. Creating an association relationship using resource-centric icon
129
Note: The resource-centric interface saves unnecessary steps to develop the once on same diagram. If you do not want to use this powerful feature, click the Use Case Diagram palette, place the mouse pointer in the desired location in the diagram pane and then click the mouse button again. An actor symbol is then created in the diagram pane. Similarly, an alternative way to connect the communication link between the use case and the actor will be to click the icon once on the Use Case Diagram palette, and then place the mouse pointer inside the actor icon. Then drag the communication link from the actor icon into the Place Order use case icon. 4.6. Repeat the above steps to create the following use cases and their association relationships with the Customer Service Assistant actor (see Figure 3.46): Check Order Status Handle Goods Return
Figure 3.46. Creating more use cases with Model Repository Tree
5.1. Place the mouse pointer within the Place Order use case, right click the use case Place Order and select Open Specification from the pop-up menu (see Figure 3.47).
Figure 3.47. Use case right click pop-up menu
5.2. Select the Description tab (see Figure 3.48). A Specification Dialog about the files associated to the element will be displayed.
Figure 3.48. Use case specification setup
131
5.3. Enter the contents for each of the elements in the use case template (see Figure 3.49) and click on the OK button to confirm the use case description.
Figure 3.49. Use case specification and template
Now, let us perform a textual analysis on the Schedule Delivery use case. 6.1. Right click the use case Schedule Delivery and then select Create Textual Analysis from the pop-up menu (see Figure 3.50).
Figure 3.50. Launching textual analysis function with a use case
6.2. The Textual Analysis window will appear. Enter the following text in the text pane (see Figure 3.51).
The Order Processing Clerk selects an order from the list of filled sales orders. The system displays the sales order details, together with the member telephone number and address. The Order Processing Clerk enters the delivery date and time after talking with the member over the phone. The system records the delivery date and time of the sales order. The system records the name of the Order Processing Clerk who has handled the sales order.
Chapter 3: Use Case Modeling and Analysis Figure 3.51. Identifying domain classes using textual analysis
133
6.3. Now highlight the word order as a candidate class, right click on the word order, select Add Text as Class in the pop-up menu (see Figure 3.52). Note all occurrences of the same actor in the problem statement are now automatically highlighted (see Figure 3.52).
Figure 3.52. Identifying candidate classes
6.4. A new candidate class is automatically created in the Candidate Class Container on the right-hand side and all occurrences of the same class in the problem statement are automatically highlighted (see Figure 3.53).
Figure 3.53. All occurrences of candidate class are highlighted
6.5. Select the Class Description cell next to the class Order. Enter a brief description about the Order class. Where necessary, adjust the size of the cell to view the whole description (see Figure 3.54).
Figure 3.54. Inputting class description for Order class
135
6.6. Repeat the above steps to create the following classes (see Figure 3.55): Sales Order Member Delivery
Figure 3.55. Candidate classes in Candidate Class Container
136 Object-oriented Technology Figure 3.56. Adding new items to Use Case Template
Note: The Add Item option appends an item at the end of the Use Case Template, while the Insert Item option creates an element after the current highlighted position of the Use Case Description. 7.2. Rename the new item as Use Case ID (see Figure 3.57).
Figure 3.57. Renaming items in Use Case Template
137
7.3. Create more items in the use case description template and fill the contents of the Place Order use case description template as shown in Figure 3.58.
Figure 3.58. The completed use case description
7.4. Repeat the above steps to complete the use case descriptions for the following use cases: Check Order Status Handle Goods Return Update Membership Record Archive Membership Register New Member Process Order Schedule Delivery Order Goods Receive Goods Deliver Goods
8.2. Place the mouse pointer in the design area and click once. A package symbol will then appear in the design area. Rename the new package as Inventory Control. Press Ctrl Enter to finish the operation (see Figure 3.59). 8.3. Resize the package symbol so that it can accommodate the use cases (see Figure 3.60). 8.4. Move each of the use cases by dragging them into the package region where it belongs or where it is a member (see Figure 3.61).
Chapter 3: Use Case Modeling and Analysis Figure 3.59. Creating a new package
139
140 Object-oriented Technology Figure 3.61. Structuring use cases into a package
Note: A package can contain other packages, and packages can be nested within a package at multiple levels. When a package is moved around the design area, all the UML elements contained inside that package are moved accordingly, while maintaining their relative positions within the package. 8.5. Repeat the above steps to create packages for the entire use case model. 8.6. Move the elements of the use case diagram by structuring the positions of the packages, the use case within the package and communication links between use cases and actors to make the diagram tidy and easier to read (see Figure 3.62). 8.7. Add the system boundary to the use case model by clicking Use Case Diagram palette and move the mouse pointer to the location on the diagram pane. Move the use cases inside the boundary in the same way as you would manipulate a package in case diagram (see Figure 3.63). on the desired system the use
Chapter 3: Use Case Modeling and Analysis Figure 3.62. Structuring the use cases into packages
141
Tip:
If a system boundary will eventually be placed in the use case model, it is better to create the boundary at the beginning before the first use case is created. This way, use cases are created inside the boundary without having to move the use cases and actors around to place them in the right position (see Figure 3.64).
Figure 3.64. Complete use case model structured into packages
Having grouped the use cases into packages according to the actors roles and responsibilities, further structure the use cases according to their common pattern as well as their interactive flow pattern. If some common behaviors are found in two or more use cases, we can factor them out by creating an <<include>> use case. On the other hand, if some alternative scenarios arise due to some special condition(s), we can handle these by introducing the <<extend>> use case(s). Now, let us structure the use case model for the Find Member Record <<include>> use case. 8.8. Click on the <<include>> icon at the top of the Handle Goods Return use case and drag it to a location in the diagram pane where the <<include>> use case is to be created. When releasing the mouse button, an <<include>> use case and a communication link between the base use case and the <<include>> use case will then be created (see Figure 3.65).
Chapter 3: Use Case Modeling and Analysis Figure 3.65. Creating a new <<include>> use case
143
8.9. Rename the <<include>> use case by typing Find Member Record in the editable text field of the untitled <<include>> use case (see Figure 3.66). at the top of the Register New 8.10. Click on the <<include>> resource icon Member use case and drag it out to where the <<include>> use case is to be created. To create an <<include>> relationship between the Register New Member use case and Find Member Record use case, drag the <<include>> resource icon to the Find Member Record <<include>> use case (see Figure 3.67). Note: If the <<include>> use case has already been created and you simply want to connect the base use case with the existing <<include>> use case, then drop the <<include>> use case into the existing Find Member Record <<include>> use case. A dependency link between the base use case Register New Member and the <<include>> Find Member Record use case will then be created.
144 Object-oriented Technology Figure 3.66. Naming the new <<include>> use case
145
8.11. We can also add a use case description to the Find Member Record <<include>> use case by: customizing the use case description for the Find Member Record <<include>> use case where necessary filling the contents of the <<include>> use case(s) in the same way as you would edit the base use cases previously (see Figure 3.68).
Figure 3.68. Use case description for the Find Member Record use case
146 Object-oriented Technology Figure 3.69. Launching the use case schedule
9.3. All the use cases in the Use Case Model are then automatically displayed in the table. Rank the use cases by choosing the appropriate option in the Combo Box. 9.4. Provide some justification for each use case in the table for future reference (see Figure 3.70).
Figure 3.70. Use Case Schedule for the Mail Order System
147
Summary
Use case modeling is the process of describing the behavior of the target system from an external point of view. Hence, use case analysis emphasizes on modeling the externally visible behavior and not the internal behavior of the system. Use case diagrams, which are artifacts of the analysis and modeling process, are used in the early stages of the system development to capture and document system requirements. In performing use case modeling and analysis, a two-stage process is followed. We first commence with the problem statement to identify the major actors and use cases of the system so as to create an initial use case diagram. The description of the behavior of each use case can then be produced, and from which candidate business classes are identified and refined using textual analysis. In the second stage, the use case model is further refined by developing the base use case descriptions, which are then iteratively elaborated to determine the <<extend>>, <<include>> and generalization relationships. The instance scenarios are then developed and use cases prioritized. To illustrate the concepts described in this chapter, the modeling and analysis of an online mail order system has been described, detailing the steps involved by using the powerful features of the VP-UML CASE tool.
Exercise
Consider the problem statement of an online book store in the Exercise of Chapter 2. Follow the steps below to develop the use case model of the system: Identify the major actors Write a description to define the roles of each actor Examine the roles of each actor and identify the use cases Draw initial use case diagrams Write initial descriptions for the use cases Perform a textual analysis to identify candidate business (domain) objects Develop the base use case descriptions Iteratively elaborate the base use case descriptions and determine the <<extend>>, <<include>> and generalization relationships. Refine the use case diagram and the use case descriptions to reflect the use case relationships.
Develop the instance scenarios. For each use case, develop the instance scenarios to cover all possible paths of execution.