Use Cases Classifier Generalizable Element is Root Model
Use Cases Classifier Generalizable Element is. Root Model Element Namespace name visibility is. Specification Constraint Body CS/SWE 421 Introduction to Software Engineering Dan Fleck (Slides adapted from Dr. Stephen Clyde with permission) Coming up: Introduction 1
Introduction n Use Case: “. . . a typical interaction between a user and a computer system”, Booch – Here, “user” is anything that needs or invokes the functionality of the system – “Computer system” is the system being modeled n n n Use cases can capture and document the user-visible functionality of a system Use cases capture how the system will benefit the user Each use case achieves a discrete goal for the user 2 Coming up: Example Use Case Diagram
Example Use Case Diagram 3 Coming up: Goals
Goals n Use cases help everyone come to a common understanding of what the system should do – Developers – End-users – Domain Experts n n Use-cases are a communication tool for the design (not the implementation) Use cases represent a functional requirement of your system (as a whole) 4 Coming up: Use Case Diagrams
Use Case Diagrams n n Use Case Diagrams provide a visual way to document user goals and explore possible functionality Three primary modeling components: – Actors – Use Cases – Relationships between use cases Record class grades Review Transcripts Teacher Authorized Staff Worker Coming up: Actors Student 5
Actors n n Actors are things outside the system that need to interact with the system Actors carry out use cases Actors are represented as stick figures Although users are actors, not all actors are users – Actors can be external software systems – External hardware (sensors, actuators, etc. ) – Actors can be people that need the functionality of the system, but may not be the ones who actually invoke the software commands 6 Coming up: Hints for Finding Actors
Hints for Finding Actors n n n Who or what will use the main functionality of the system? Who or what will provide input to this system? Who or what will use output from this system? Who will need support from the system to do their work? Are there any other software systems with which this one needs to interact Are there any hardware devices used or controlled by this system? 7 Coming up: Hints for Modeling Actors
Hints for Modeling Actors n n n An actor can be a role that a user plays with respect to the system A single person may play different roles A single actor may perform many use cases A use case may be performed by many actors Show external systems as actors only when they are the ones who need a use case 8 Coming up: Relationships Between Actors
Relationships Between Actors n n Actors cam be related by generalization/specialization Actors are classifiers (not individual users) Student Coming up: Use Cases Graduate Student en h w us s hi vio t Do ry ob ve 9
Use Cases n n Each use case represents something the user needs to do with the system – a goal A use cases is given a short name and textual description Use cases can be large or small from a conceptual perspective Use cases can relate to each other via dependencies, such as – <<extends>> – <<includes>> – Generalization or <<refines>> (“is a”) 10 Coming up: Use Case Relationships
Use Case Relationships Includes Extends Generalization After a while you realize extends and generalization are not too different. Just know generalization and includes… forget about extends (the difference is only in intent) 11 Coming up: Use-Case Relationships
Use-Case Relationships n Includes Dependency: Defines how one use can invoke behavior defined by another use case Alter Student Grade <<includes>> Teacher Record Grades for a Section 12 Coming up: Use-Case Relationships
Use-Case Relationships n Extends dependency: defines a use-case that is a variation of another, usually for handling an abnormal situation Alter Student Grade <<extends>> Alter student grade for a class taken more than a year ago Authorized Staff Worker 13 Coming up: Use-Case Relations
Use-Case Relations n Generalization: Defines one use case as a generalization of another. Alter Student Grade Teacher Alter Student Grade for a Graduate Course 14 Coming up: Hints for Finding Use Cases
Hints for Finding Use Cases n Try listing actors first and then look at the activities each needs to perform and then try to express the goal that represent these activities – although this will uncover many valuable use cases, it will not find them all n Try listing external events and then look at what the system needs to do in response to each one. – This technique will find some additional use cases, but not all n n Be patient, allow the use cases to unfold Don’t over do it – Use Case Diagram should be broad-brush characterizations of user goals 15 Coming up: Hints for Modeling Use Cases
Hints for Modeling Use Cases n n n Establish the context of a user goal by identifying the actors For each actor, consider the behavior that it expects or requires the system to provide Name these common behaviors as use cases Factor common behavior into new use cases Relate the use cases using the extend, includes, and refines dependencies Adorn uses cases with notes 16 Coming up: Benefits of Use Cases
Benefits of Use Cases n n n Use cases diagrams capture user-visible functions Identifying actors help capture who needs the system functionality Relationships between use cases document opportunities for reuse Use cases provide a basis planning and scheduling incremental development Use cases can provide a basis for system testing 17 Coming up: In Class Exercise
In Class Exercise n Lets create a use case diagram for – i. Pod – Television set – Elevator – ATM – Online Scrabble game – Word Processor 18 Coming up: Use cases for CS 421
Use cases for CS 421 Show system boundary Show Actors outside boundary Use extend, include, generalization/spe cialization where appropriate Coming up: Use cases for CS 421 Typically one diagram for your project is 19 sufficient
Use cases for CS 421 Show system boundary (Warning: skip this if not supported by the tool – like Netbeans!) 20 Coming up: Use cases for CS 421
Use cases for CS 421 n For each use-case (oval) in your diagram include the use-description text described in the slide for Chapter 5, titled: n Use Case Description –about slide #14 21 Coming up: Questions
Questions n n n n Who might be interested in reviewing or using use case diagrams? When in the development life cycle should we employ use cases? What do use cases have to do with object-orientation? What level of use-case granularity is best? How many use cases are enough? Can other modeling activities help in discovering use cases? When in the development life cycle do we stop referring to or refining the use cases? What should the text description of use case contain? 22 Coming up:
n Backup Slides n The following slides were removed over time. 23 Coming up: Extends vs. Includes vs. Generalization
- Slides: 23