You are on page 1of 12

Object - Oriented Programming & Design Part IX - UML Use Case Diagrams

Copyright © 1996 - 2003 David Leberknight & Ron LeMaster. All rights reserved.

Requirements / Use Case Specification

Your way of echoing to the customer what you heard him/her say he/she needs.

Traditional, textual specification:
l l l

System functionality is often well documented. The user interface is often under-specified. Depends heavily on skill of the writers.

Use Case modeling:
l l l l l

Analysis tool that helps clarify the system requirements. Models the users’view of the system. Form basis for developing test cases. Has its own visual modeling language. Used to validate the object model.

Copyright © 1996 - 2003 David Leberknight & Ron LeMaster. All rights reserved.

( IX ) UML Use Case Diagrams - 2

Each type has its own pricing and rental terms (length of rental and overdue policy). old releases. which of them are overdue. ( IX ) UML Use Case Diagrams . based on use case modeling. ( IX ) UML Use Case Diagrams .2003 David Leberknight & Ron LeMaster. Objectory. Customers must register with the store before they can rent videos. phone number. l l l l The store’ s inventory consists of new releases. driver’ s license. l Jacobson and colleagues developed a software engineering tool. and videos for sale. The store tracks the videos that each customer currently has rented. A customer under the age of 17 cannot rent videos with ratings of R. bargain movies. All rights reserved. unless the store has an authorization slip on file. who wrote several widely read and highly regarded books about their use.4 . Copyright © 1996 . Registration information includes standard demographic information such as address.Genesis of Use Cases Developed by Ivar Jacobson.2003 David Leberknight & Ron LeMaster. signed by a parent or guardian. etc. or NC-17. X.3 Example: Video Store You are to design a system to track the activities of a video store. All rights reserved. l Folded directly into UML l Widely used in industry l Copyright © 1996 . and what outstanding overdue charges the customer is liable for.

. The customer either pays the charges at that time.. Copyright © 1996 . or they are accrued to his or her account. When it is returned. All rights reserved. The store keeps track of how many times each specific video has been rented. a rental agreement is generated. l What types of requirements have not been addressed? Copyright © 1996 .2003 David Leberknight & Ron LeMaster. and the customer pays the nominal rental fees for them. Write text describing the basic course of each use case along with any interesting variations (scenarios).6 . where appropriate. it goes back into in-store inventory. overdue charges are determined. ( IX ) UML Use Case Diagrams .) l l l When a video is rented. Make a Use Case Model. This enables the store to track popularity. When the videos are returned.5 Video Store Use Cases Rent Video Return Video User Buy Video Authorize Child • We will refactor this simple diagram as we iterate. ( IX ) UML Use Case Diagrams . and retire tapes when they have been viewed many times. When a customer rents one or more videos. All rights reserved. it is moved from in-store inventory to the customer’ s possession.Video Store Management Application (cont.2003 David Leberknight & Ron LeMaster.

Generality. Robustness.2003 David Leberknight & Ron LeMaster. Maintainability ($$$). Flexibility.8 . Reliability Frequency/Severity of Failure. Compatibility. All rights reserved. Throughput. ( IX ) UML Use Case Diagrams . Create one to a few system operations that will accomplish the use case. Identify important scenarios for each system operation. Security. Consistency. Mean Time to Failure. add the following to the class diagram: – New classes – Operations – Associations – Dependencies – Navigability indicators on associations Copyright © 1996 .2003 David Leberknight & Ron LeMaster. Accuracy. Simplicity. ( IX ) UML Use Case Diagrams . Base on the interaction diagrams. Localizability. Adaptability. Configurability. Usability Human Factors. Serviceability. All rights reserved. Installability. Efficiency. Copyright © 1996 . Resource Consumption. Identify candidate classes. Response Time. Aesthetics. Supportability Testability. Documentation. Pick a controller class for each system operation. l l Performance Speed. Recoverability.Use Case Driven Design l l l l l l l Pick a use case. Predictability.7 Requirements: FURPS l l l Functionality User Goals & Feature Set (Use Cases go here). Create an interaction diagram for each interesting scenario. Extensibility.

and sometimes the operating system.” An alternative to Use Case Modeling is to write a requirements document that declares what the system will have to do (often using FURPS). etc… ” Guidelines: IEEE Std 1233. l Use Cases and FURPS complement one another.” – Testability: “The degree to which a requirement is stated in terms that permit establishment of test criteria. ( IX ) UML Use Case Diagrams .2003 David Leberknight & Ron LeMaster. and performance of tests to determine whether those criteria have been met.” » “The employee phone book will be like an organization chart.10 . organized by groups. organized alphabetically by name. Copyright © 1996 . 1998 Edition FURPS: Grady. All rights reserved.2003 David Leberknight & Ron LeMaster. All rights reserved.9 Requirements Definitions and References l l l Some definitions: – Requirement: “A condition or capability needed by a user to solve a problem or achieve an objective. ( IX ) UML Use Case Diagrams . including the users (actors).Requirements Specification l Don’ t be afraid to declare non-quantitative requirements: – Ease of use – Interface metaphor » “The employee directory will be like a phone book. Hewlett Packard Copyright © 1996 .” – System Context: “Everything that lies outside of the system.

l l l Start with the “success” scenario that accomplishes the user’ s goal.2003 David Leberknight & Ron LeMaster. l A Use Case Model helps to scope a project. but do not declare them. Sequence Diagrams are useful to illustrate the dynamic interactions for one scenario. l The model describes what the system should do without specifying how it should be done. All rights reserved. ( IX ) UML Use Case Diagrams . Scenarios are used to validate the entire design. l A Use Case Model is NOT a complete requirements specification. or scenarios.Use Case Model Use Case Models organize Functional Requirements in ways meaningful to users. All rights reserved. both people & machines. system administrator. Scenario 3: Rodney Randle fails to rent Rambo because of too many overdue videos. Copyright © 1996 . Examples: general user. describing their interactions with the system in support of their goal(s). ( IX ) UML Use Case Diagrams . The models must support the functionality represented by the entire suite of scenarios. Additional text and UML models provide more details. l Use Cases are high-level descriptions of system processes. Scenario 2: Rita Randle rents Roman Holiday using Rodney’ s account. A Use Case specifies the smallest unit of functionality that should ever be delivered. l Actors model the different user roles in a system. workflows.12 . designed to help ensure that the system behavior is what the users require. the payroll subsystem. Copyright © 1996 . l Use Cases imply requirements through the stories they tell.11 Use Cases and Scenarios l A Scenario is an instance of a Use Case – – – – Use Case: A customer rents a video. Scenario 1: Rodney Randle rents Rambo. then add in the failure modes.2003 David Leberknight & Ron LeMaster. and serve as a basis for developing test cases.

UML Use Case Model Symbols Use Case 1 Actor 1 << include >> Use Case 2 Use Case req'd to Achieve Use Cases 1 and 2 << extend >> Extends behavior of Use Case 1 << include >> Use Case 3 Specialization of Actor 1 l l Specializes behavior of Use Case 3 Some people use <<uses>> instead of <<include>> Difference between <<extend>> and specialization is fuzzy ( IX ) UML Use Case Diagrams .13 Copyright © 1996 . All rights reserved.. Example Use Case Documentation Use Case Name: Generate Report XYZ Author: Ron LeMaster Last Revision: January 1st. Pre-conditions: XYZ data has been loaded.2003 David Leberknight & Ron LeMaster. Basic Course: l Allow the user to specify XYZ report parameters. Extends: none. ( IX ) UML Use Case Diagrams ..ucd Copyright © 1996 . 2000 Actors: XYZ Analyst. Uses: none. Error Conditions: . All rights reserved. l Invoke the XYZ report generation process. Other Scenarios: Post-conditions: An XYZ Report is created.2003 David Leberknight & Ron LeMaster. Notes: Refer to Use Case Diagram T:\abc123.14 .

Maybe get parental authorization for a minor? 2. Update child’ s Database record showing the transaction. All rights reserved.. Get customer ID or generate new one.2003 David Leberknight & Ron LeMaster. Get Parental Authorization for Minors to Rent/Buy R or X movies < Extends: Edit Customer Profile > Get parent and child customer IDs. Retire Video ( IX ) UML Use Case Diagrams .15 Video Store Use Cases 1.16 . ( IX ) UML Use Case Diagrams . 3. Copyright © 1996 . Generate purchase agreement with customer’ s ID and “today”. Edit Customer Profile Input new or updated demographic data.. Write new or updated customer record to Database.2003 David Leberknight & Ron LeMaster. < Uses: Scan Video Barcode > .Video Store Use Case Model << extend >> Edit Customer Profile Parental authorization Customer Service Representative Pay Late Fees Sell Video(s) << include >> Return Video(s) << include >> Get Video ID << include >> Rent Video(s) << include >> << include >> Add Video Scan Barcode Type ID Store Manager Copyright © 1996 . All rights reserved. Sell Video(s) Get customer ID.

Tell customer grand total late fee still unpaid. Write updated rental agreement(s) to Database. Mark each video as being sold in Database and save new purchase agreement. Find all open rental agreements for customer in Database. if any.Video Store Use Cases (cont. Note video ID on purchase agreement. Return Video < Uses: Scan Video Barcode > Find most recent open rental agreement with this video and this customer. remind customer of movie and fee. Copyright © 1996 . . 4. Rent Video(s) Get customer ID. Remind customer of all rented movies still outstanding.) 5. < Uses: Scan Video Barcode > Verify that customer can rent video.2003 David Leberknight & Ron LeMaster. Get next video being purchased. Get next video being rented. Note video ID on rental agreement. Generate rental agreement with customer’ s ID and “today”. if any. / Mark as paid on rental agreement. if rated X or R. Collect money owed. if rated X or R.. 6. ( IX ) UML Use Case Diagrams . Mark each video as being rented in Database and save new rental agreement. If no late fees due & no outstanding videos. if any. Iterate. All rights reserved.) Verify that customer can buy video.18 . along with fee paid. Note “today” on rental agreement (returned date) for this video.. if any. if any. Iterate. Inform Customer of length of rental and overdue policy. All rights reserved.2003 David Leberknight & Ron LeMaster. along with fee paid.17 Video Store Use Cases (cont. Calculate days late. For each movie with a late fee. ( IX ) UML Use Case Diagrams . Copyright © 1996 . mark rental agreement closed. Pay Late Fees Get customer ID.

If no late fees due and no more outstanding videos for this rental agreement. price.2003 David Leberknight & Ron LeMaster. ( IX ) UML Use Case Diagrams . Mark video as returned in the Database.) 8.) If late. Know video’ s ID.Video Store Use Cases (cont. Copyright © 1996 . All rights reserved. Copyright © 1996 . 7. < Uses: Scan Video Barcode > Mark video as being in store. 9.19 Video Store Use Cases (cont. Write updated rental agreement to the Database. < Uses: Scan Video Barcode > Mark video as being retired. rating. mark it closed. etc.20 . and mark it on rental agreement as unpaid. calculate late fee to be paid. Scan Video Barcode Scan it. Write updated video record to Database. ( IX ) UML Use Case Diagrams . Retire Inventory Determine which videos are too old or unpopular (maybe with SQL queries against database).2003 David Leberknight & Ron LeMaster. Generate new video ID. Add Inventory Input video’ s data (title. Write new video record to Database.). All rights reserved.

etc. Then model failure scenarios as either << extends >> or as alternate scenarios. l System: Show customer info. ( IX ) UML Use Case Diagrams . identify one use case.. whichever is simpler. l . l Actor: For each video to rent. scan the barcode. l as user/system conversations (visualize w/ UML Sequence Diagrams) For example. All rights reserved. l Actor: Record customer payment. and an architectural vision.2003 David Leberknight & Ron LeMaster. UI screen detail. user goals.. Copyright © 1996 . video titles. etc. All rights reserved. Annotate other useful information in a textual document: such as the steps performed by the system. l System: Display accumulated rental fees..2003 David Leberknight & Ron LeMaster. A Video Store Rent Videos scenario could be elaborated using Rebecca Wirfs-Brock’ s conversational style: l Actor: Clerk enters customer ID into system. Who are the actors (user roles)? What are their responsibilities and goals? For every user goal. including outstanding late fees. Look for commonality to identify << include >> relationships. business rules that must be invoked/enforced.. Review FURPS. . as a high level description of business scenario.22 Copyright © 1996 .Style Choices A Use Case can be described: l textually. ( IX ) UML Use Case Diagrams . l System: Generate receipt.21 The Requirements Gathering Process l l l l l l l l Start with important business processes. Do the simple “success” use cases first: the goal succeeds.

2003 David Leberknight & Ron LeMaster. Copyright © 1996 . Only describe the internal behavior of the system to a level of detail that the actor would know about. All rights reserved. ( IX ) UML Use Case Diagrams . Remember. and not necessarily detailed functional decomposition and sequencing. analysis) class diagram(s) in conjunction with use case elaboration. Beware of using use cases as “functional decomposition” in disguise! An object is not a function! Use cases should be used to help find objects and their responsibilities. not design.) l l l l Model the domain (conceptual perspective. don’ t be fooled by the frequent use of UML sequence diagrams. Resist the urge to describe the detailed implementation of a scenario.2003 David Leberknight & Ron LeMaster.Requirements Gathering (cont. The Project Manager (along with the customer and developers) should prioritize the Use Cases when planning development iterations and deliverables. we’ re doing requirements analysis.24 .23 Vocabulary l l l l l l Requirements Analysis Use Case Scenario Actor << extends >> / << include >> FURPS – Functionality – Usability – Reliability – Performance – Supportability Copyright © 1996 . All rights reserved. ( IX ) UML Use Case Diagrams . use other kinds of UML models. save that for other UML diagrams. but keep them separate.