UWO Computer Science Use Case Diagrams15 UML Use Case Diagram What Are Your Users Goals? Use case diagrams are a simple UML notation to illustrate the goals of your users Use cases Are created in the early stages of the project Are an effective means of communicating with your end users Allow you to model what happens in an existing system or what the user can do in a new system Can be used as the basis for picking test cases during the testing of the system. A use case represents a sequence of actions (or goal) to be performed by the system and the users/actors who interacts with that use case
UWO Computer Science Use Case Diagrams16 Simple Example Suppose a gambler is playing a dice game where if he/she roll 2 dice and the values of the dice add up to 7 he/she wins, otherwise he/she loses. Sample Use Case Diagram: Roll A Die Gambler
UWO Computer Science Use Case Diagrams17 Terminology Use Case: a goal to be accomplished, a sequence of activities that achieve that goal Normally a verb followed by a noun, for example: Process Sale Add Customer E.g. Bad Use Case: Log In (the goal is not really to log in!) E.g. Good Use Case: Authentic User Notation: Process Sale
UWO Computer Science Use Case Diagrams18 Terminology Actor: people/systems that interact with use cases Human Actors: Clients, Customers, Employees —Pick clear names such as Hotel Desk Clerk, Librarian, Head Librarian. —Don’t pick names based just on job titles: for example if the clerk, the secretary and the receptionist all do the same operations on the telephone answering system you are writing, pick one name for all 3, not 3 different actor names,e.g. phone operator —Notation: Gambler
UWO Computer Science Use Case Diagrams19 –Non-Human Actors: External systems that communicate with the system being designed e.g. Credit Card Authorization, Web Server Ignore internal components, only model external other systems as actors, not internal parts of your system. For example, your internal database should NOT be an actor. Notation: Or > Credit Card Authorization System
UWO Computer Science Use Case Diagrams20 Suggestions for Designing Use Cases Choose a good name e.g. Add Appointment rather than Make Time Show a complete and completable behaviour e.g. Add Appointment rather than Add Appointment Location e.g. Add Appointment rather than Adding Appointment Show inverse use cases if applicable e.g. Add Appointment AND Delete Appointment Limit a use case to ONE behaviour e.g. Add Appointment, Update Appointment AND Delete Appointment rather than Manage Appointments Write the use case from the actors point of view e.g. Sell Stock rather than Delete Stock
UWO Computer Science Use Case Diagrams22 Use Case Example Design the use case diagram for the following situation: Suppose we are re-designing a system for BustBlocker Video Stores. Currently, a customer picks a video off a shelf and brings it to the clerk. The clerk logs in once in the morning and during the rest of the day must check out the video to a customer or check in videos that are returned by customers. The clerk or the store manager must also be able to add new copies of movies and delete copies of movies. When a customer pays for a video, the clerk will use the check credit card system to check the user’s credit card. The clerk and the store manager must be able to add and delete and update customer information. Customers want to have a printed list of the movies they have rented within a given time frame, the clerk must print this list.
UWO Computer Science Use Case Diagrams23 Video Use Case Diagram 1
UWO Computer Science Use Case Diagrams24 Video Use Case Diagram 2 How would your diagram change if you were going to allow customers to do self check out and self check in of movies and print their own list.
UWO Computer Science Use Case Diagrams26 Use Cases that can be reused > Try to factor out common behaviour from 2 or more use cases, a subscenario of a use case Example: Event Organizer Guest Book RoomBook Hall Guarantee Reservation >
UWO Computer Science Use Case Diagrams27 Advantages Helps to avoid documenting the same information in more than 1 detailed use case Helps identify common functionality for later coding decisions Disadvantages Might cause UML designers to start looking to early for common functionality rather than just identifying the use cases. Not as easy to read for non-UML users so it may make diagrams more confusing for users
UWO Computer Science Use Case Diagrams28 Identifying Different Scenarios > If a use case has a complex or unusual scenario, you might want to make it a separate use case If there is some point where the behaviour diverges, you might want to make this a separate use case
UWO Computer Science Use Case Diagrams29 Example Note: the arrow goes from the more exceptional case to the normal case Customer Rent Video Rental Refused > Overdue videos still on loan
UWO Computer Science Use Case Diagrams35 Other Things to Remember At this early point in requirements analysis, DO NOT attempt to design screens for your use cases, just identify them. i.e. don’t worry about how the use cases work, just worry about what the use cases are. Match the actors name to how he/she interacts with the system, not to his/her job title Use cases should be easy for your users to understand, again remember they tell what the user must accomplish NOT how to accomplish it!
UWO Computer Science Department36 Case Study Design a Use Case Diagram for the following requirements: A camping reservation system for multiple campgrounds. Each campground has a manager and rangers. Managers and rangers can enter information such as campsite info, and which sites are useable and which sites are undergoing repair/regrowth. Campers can use the system to select and reserve camping locations. Identify the actors Identify the use cases Look for any include use cases Look for any extend use cases Which use case might you want to expand to a DETAILED USE CASE?
UWO Computer Science Department37 Your Answer Add Site List Sites > Search sites Book site Cancel booking Modify Site Delete Site > Modify booking Ranger Camper > Check Availability
UWO Computer Science Use Case Diagrams39 The “Guts” of Use Cases –We can now supply the details of a use case 1.Define use cases (as done above) 2.Give a simple sentence to explain each use case 3.Give a detailed narration of what the use case does, in paragraph form 4.Describe the main course scenario (main success scenario, main flow) 5.Set pre and post conditions 6.Identify, then describe alternate scenarios with post and pre conditions 7.List any additional requirements that must be met –The users should be allowed to review the narrative to see if it clearly reflects the goal the user is trying to accomplish
UWO Computer Science Use Case Diagrams40 Example 1. Use Case Name: Check out video 2. Description: This use case allows the actor, clerk, to rent out a video to a particular customer 3. Narrative: This use case starts with the clerk entering in the video id number of the video to be rented. The system displays the video title and how many copies are available. If no copies are available, the action is cancelled. If there is at least one copy available, the system prompts for customer’s id number. If the name displayed matches the customer name the system prompts for the payment information. The clerk enters in the customers credit card number which is authorized by the credit card authorization system, if the card is not valid, the customer is asked if he/she wishes to pay with cash, if he/she says no, the action is cancelled. Otherwise the system displays the return date for the video and gives a confirmation message that the video was rented. Review this narrative with your users before continuing!
UWO Computer Science Use Case Diagrams41 4.Main Course: Actor: ClerkSystemActor: Credit Card Authorization System 1. The clerk enters the video id number of the movie to be rented. 3. The clerk enters the customer id number 5. The clerk enters the customers credit card number 8.The clerk confirms the checking out of the movie 2. The system displays the name of the movie and the number of copies available 4. The system displays the customers name. 6. The system sends the card number to the credit card authorization system and waits for confirmation 9. The system displays that the video was rented and displays the return date 7. Reports card is accepted.
UWO Computer Science Use Case Diagrams42 5.Pre Condition: At least one copy of the movie to be rented is available. Post Condition: The video copy is rented to the customer 6.Alternate Course 1: There are no copies of movie available Pre Condition: At Step 1 of main course, the actor enters a movie where all the copies have been rented Post Condition: Video is not rented to the customer 7.Other Design Considerations: 1.If 2 or more clerks try to rent the same copy at the same time, the system should allow only one of them to rent it Actor: ClerkSystem 1.The clerk enters the video id number of the movie to be rented. 3. The clerk cancels the check out operation 2. The system displays the name of the movie and that there are ZERO copies available
User Stories There are problems with drawing a Use Case Diagram based on the initial requirements that were given you. Can you guess what some of the problems are? The initial requirements might be wrong OR incomplete OR change during the project. I.e. the user changes his/her mind or thinks up new features. Called: Scope Creep So….. How can we keep our requirements “Agile”? Chapter 4: Developing requirements47