Use Cases And Scenarios - Michigan State University

Transcription

CSE870: Adv. Software EngineeringRESEMDEUse Cases and ScenariosCSE870: Advanced Software Engineering: UML-- Use CasesRESE1We Will CoverMDE What is a use-case– Use-case versus user interaction Use-Case diagrams– The constructs in the use-case diagrams Capturing the use-case– High-level use-case– Extended use-case– Difference between use case and scenarioCSE870: Advanced Software Engineering: UML-- Use CasesCSE870: Advanced Software Engineering(UML)21

CSE870: Adv. Software EngineeringRESEWhat is a Use-CaseMDE A use-case captures some user visible function This may be a large or small function– Depends on the level of detail in your modeling effort A use-case achieves a discrete goal for the user Examples– Format a document– Request an elevator How are the use cases found (captured orelicited)?CSE870: Advanced Software Engineering: UML-- Use CasesUser Goals versusUser InteractionsRESE3MDE Consider the following when formatting a document Define a style Change a style Copy a style from one document to the next– versus Format a document Ensure consistent formatting of two documents The latter is a user goal– Something the user wants to achieve The former are user interactions– Things the user does to the system to achieve the goalCSE870: Advanced Software Engineering: UML-- Use CasesCSE870: Advanced Software Engineering(UML)42

CSE870: Adv. Software EngineeringRESEGoals and InteractionsMDE There is a place for both goals and interactions Understand what the system shall do– Capture the user goals Understand how the user will achieve the goals– Capture user interactions– Sequences of user interactions Thus, start with the user goals and then refinethe user goals into several (many) userinteractionsCSE870: Advanced Software Engineering: UML-- Use CasesRESEMDE5Point of Sale Terminal (POST) Computerized system to record sales andhandle payments Typically used in a retail store Includes HW components, such as computerand bar code scanner Software to run the system Goals of system:– Increase checkout automation– fast and accurate sales analysis– automatic inventory controlCSE870: Advanced Software Engineering: UML-- Use CasesCSE870: Advanced Software Engineering(UML)63

CSE870: Adv. Software EngineeringREUse-Case Diagrams (POST)MDESEPOST: Point of Sale TerminalUse CasePOSTSystem BoundaryBuy ItemLog InCashierCustomerRefund a Purchased ItemAdapted from Larman “Applying UML and Patterns”CSE870: Advanced Software Engineering: UML-- Use CasesRESE7Another ExampleMDEFinancial Trading SystemSet LimitsUpdate AccountsTrading ManagerAccounting SystemAnalyze Risk«includes»Valuation«includes»Price DealTraderCapture Deal«extends»Adapted from Fowler “UML Distilled”Limit ExceededCSE870: Advanced Software Engineering: UML-- Use CasesCSE870: Advanced Software Engineering(UML)Salesperson84

CSE870: Adv. Software EngineeringRESEIncludes and ExtendsMDE Extends Includes/Uses– A use-case is similar toanother one but does a little bitmore– Put the normal behavior in oneuse-case and the exceptionalbehavior somewhere else– You have a piece ofbehavior that is similaracross many use cases– Break this out as a separateuse-case and let the otherones “include” it– Examples include Capture the normal behavior Try to figure out what can gowrong in each step Capture the exceptional casesin separate use-cases Valuation Validate user interaction Sanity check on sensorinputs Check for properauthorization– Makes it much easier tounderstandCSE870: Advanced Software Engineering: UML-- Use CasesRESE9Setting the System BoundaryMDE The system boundary will affect youractors and use-casesPOSTBuy ItemLog InCashierCustomerRefund a Purchased ItemAdapted from Larman “Applying UML and Patterns”CSE870: Advanced Software Engineering: UML-- Use CasesCSE870: Advanced Software Engineering(UML)125

CSE870: Adv. Software EngineeringRESEA Different BoundaryMDE Let us view the whole store as our systemStoreBuy ItemRefund a Purchased ItemCustomerAdapted from Larman “Applying UML and Patterns”CSE870: Advanced Software Engineering: UML-- Use CasesRESE13Partial POSTMDEPOSTBuy ItemLog InCashierCustomerRefund a Purchased ItemStart UpManagerManage UsersSystem AdministratorAnd a Lot MoreAdapted from Larman “Applying UML and Patterns”CSE870: Advanced Software Engineering: UML-- Use CasesCSE870: Advanced Software Engineering(UML)146

CSE870: Adv. Software EngineeringRESEPOST Use-CaseMDEUse case:Buy ItemActors:Customer (initiator), CashierType:PrimaryDescription:The Customer arrives at thecheckout with items to purchase.The Cashier records the purchaseitems and collects a payment.On completion the Customerleaves with the itemsCSE870: Advanced Software Engineering: UML-- Use CasesRESEMDEUse case:Actors:Type:Description:Cross Ref.:Use-Cases:15POST Expanded Use-CaseBuy ItemCustomer (initiator), CashierPrimary and essentialThe Customer arrives at the checkout with itemsto purchase. The Cashier records the purchaseitems and collects a payment. On completion theCustomer leaves with the items.Requirements XX, YY, and ZZCashier must have completed the Log In use-caseCSE870: Advanced Software Engineering: UML-- Use CasesCSE870: Advanced Software Engineering(UML)167

CSE870: Adv. Software EngineeringRESEThe Home Heating SystemMDEWater ValveWater PumpHot WaterHomeControllerBurnerFuel Valve908070FuelOffOn6050Control PanelTemp SensorCSE870: Advanced Software Engineering: UML-- Use Cases17RESEMDEHome Heating Use-Case DiagramHome HeatingPower UpPower DownHome OwnerChange Temp.CSE870: Advanced Software Engineering: UML-- Use CasesCSE870: Advanced Software Engineering(UML)188

CSE870: Adv. Software EngineeringRESEMDEHome Heating Use-CasesUse case:Actors:Type:Description:Power UpHome Owner (initiator)Primary and essentialThe Home Owner turns the power on. Each roomis temperature checked. If a room is below thethe desired temperature the valve for the room isopened, the water pump started, the fuel valveopened, and the burner ignited.If the temperature in all rooms is above the desiredtemperature, no actions are taken.Requirements XX, YY, and ZZNoneCross Ref.:Use-Cases:CSE870: Advanced Software Engineering: UML-- Use CasesRESE19Modified Home HeatingMDEHome HeatingTemp. HighPower Up«includes»«includes»Power DownAdjust Temp«includes»Home Owner«includes»Change Temp.Temp. LowCSE870: Advanced Software Engineering: UML-- Use CasesCSE870: Advanced Software Engineering(UML)209

CSE870: Adv. Software EngineeringRESEMDEHACS Homework assignment and collection are an integral part of anyeducational system. Today, this task is performed manually.What we want the homework assignment distribution andcollection system (HACS for short) to do is to automate thisprocess. HACS will be used by the instructor to distribute the homeworkassignments, review the students’ solutions, distributesuggested solution, and distribute student grades on eachassignment. HACS shall also help the students by automatically distributingthe assignments to the students, provide a facility where thestudents can submit their solutions, remind the students whenan assignment is almost due, remind the students when anassignment is overdue.CSE870: Advanced Software Engineering: UML-- Use CasesRESEMDE21In-class exerciseWork in Pairs Create use case diagram Have an example of includes relationship Bonus: have an example of extends relationship Remember to include key elements ofUC diagram.CSE870: Advanced Software Engineering: UML-- Use CasesCSE870: Advanced Software Engineering(UML)2210

CSE870: Adv. Software EngineeringRESEMDEHACS Use-Case DiagramConfigure HACSDistribute AsignmentsHACSRemind StudentGet AssignmentSystem AdminPost SolutionsSubmit AssignmentStudentDistribute GradeGet SolutionInstructorGet GradeCSE870: Advanced Software Engineering: UML-- Use CasesRESE23HACS Use-CasesMDEUse case:Actors:Type:Description:Distribute AssignmentsInstructor (initiator)Primary and essentialThe Instructor completes an assignment and submitsit to the system. The instructor will also submit thedue date and the class the assignment is assigned for.Cross Ref.:Use-Cases:Requirements XX, YY, and ZZConfigure HACS must be done before any user(Instructor or Student) can use HACSCSE870: Advanced Software Engineering: UML-- Use CasesCSE870: Advanced Software Engineering(UML)2411

CSE870: Adv. Software EngineeringRESEAlternate HACSMDEHACSConfigure HACSDistribute AsignmentsSystem AdminPost SolutionsDistribute GradeStudentInstructorRemind StudentSubmit AssignmentCSE870: Advanced Software Engineering: UML-- Use CasesRESE25When to use Use-CasesMDE In short, always!!! Requirements is the toughest part of softwaredevelopment– Use-Cases is a powerful tool to understand Who your users are (including interacting systems) What functions the system shall provide How these functions work at a high level Spend adequate time on requirements and in theelaboration phaseCSE870: Advanced Software Engineering: UML-- Use CasesCSE870: Advanced Software Engineering(UML)2712

Use-Case Diagrams (POST) CSE870: Advanced Software Engineering: UML-- Use Cases 7 Cashier Customer Buy Item Log In Refund a Purchased Item POST Use Case System Boundary Adapted from Larman “Applying UML and Patterns” POST: Point of Sale Terminal MDE RE SE Another Example CSE870: Advanced Software Engineering: UML-- Use Cases 8 Salesperson .File Size: 299KB