Intro to UML - Use Case diagrams

4,953 views

Published on

Published in: Education
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,953
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
260
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Intro to UML - Use Case diagrams

  1. 1. UML Behavioral Modeling Diagrams Use Case diagrams Jerry Myong
  2. 2. Use Cases <ul><li>For analysts who want to model user and system interactions. </li></ul><ul><ul><li>Define behavior, requirements and constraints in the form of scripts or scenarios. </li></ul></ul><ul><li>Use Case Model </li></ul><ul><ul><li>Captures the requirements of a system. </li></ul></ul><ul><ul><ul><li>Communicates with users and other stakeholders what the system is intended to do . </li></ul></ul></ul><ul><ul><li>Components </li></ul></ul><ul><ul><ul><li>Actors - external entities are referred to as actors. </li></ul></ul></ul><ul><ul><ul><ul><li>Represent roles which may include human users, external hardware or other systems. </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Usually drawn as a named stick figure, or alternatively as a class rectangle with the «actor» keyword. </li></ul></ul></ul></ul><ul><ul><ul><li>Use cases - a single unit of meaningful work </li></ul></ul></ul><ul><ul><ul><ul><li>Provides a high-level view of behavior observable to someone or something outside the system. </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Notation for a use case is an ellipse. </li></ul></ul></ul></ul><ul><ul><ul><li>Uses connector - connecting line with an optional arrowhead showing the direction of control (refer to “System Boundary” diagram below) </li></ul></ul></ul><ul><ul><ul><ul><li>May have multiplicity (e.g., 0 .. 1, 0 .. *) values at each end </li></ul></ul></ul></ul>
  3. 3. Use Cases <ul><li>Use case typically includes: </li></ul><ul><ul><li>Name and description - Normally named as a verb-phrase and given a brief informal textual description. </li></ul></ul><ul><ul><li>Requirements - Define the formal functional requirements that a use case must supply to the end user. </li></ul></ul><ul><ul><ul><li>Correspond to the functional specifications found in structured methodologies. </li></ul></ul></ul><ul><ul><ul><li>Requirement is a contract or promise that the use case will perform an action or provide some value to the system. </li></ul></ul></ul><ul><ul><li>Constraints - Condition / restriction that a use case operates under and includes pre and post conditions. </li></ul></ul><ul><ul><ul><li>Pre - Conditions that need to be met before the use case can proceed. </li></ul></ul></ul><ul><ul><ul><li>Post - Conditions that must be true after execution of the use case. </li></ul></ul></ul><ul><ul><li>Scenarios - Formal description of the flow of events that occur during the execution of a use case instance. </li></ul></ul><ul><ul><ul><li>Defines the specific sequence of events between the system and the external actors. </li></ul></ul></ul><ul><ul><ul><ul><li>Normally described in text </li></ul></ul></ul></ul><ul><ul><ul><ul><li>*Corresponds to the textual representation of the sequence diagram . </li></ul></ul></ul></ul><ul><ul><li>“ Included” Use Case </li></ul></ul><ul><ul><ul><li>A reference to an included use case has the following syntax: </li></ul></ul></ul><ul><ul><ul><ul><li>[condition_statement] “include” use_case_name </li></ul></ul></ul></ul><ul><ul><ul><li>The included use case describes a lower-level goal (more detailed) than the base use case. </li></ul></ul></ul><ul><ul><ul><li>Every step in a use case is written as sentence about a goal that succeeds. </li></ul></ul></ul><ul><ul><ul><ul><li>If the goal is broken out into its own use case, then the step &quot;calls&quot; the sub-use case, or it &quot;includes the behavior&quot; of the &quot;included&quot; use case. </li></ul></ul></ul></ul><ul><ul><ul><ul><li>The verb phrase part of that sentence is the name of a potential sub-use case (“Included” Use Case). </li></ul></ul></ul></ul>
  4. 4. Use Cases <ul><li>“ Extending” Use Case </li></ul><ul><ul><li>A base use case can have several extension points </li></ul></ul><ul><ul><li>Each extension point has a unique name that identifies one or several locations in the behavior sequence of the base use case </li></ul></ul><ul><ul><ul><li>Extension point – is where an extending use case is added </li></ul></ul></ul><ul><ul><ul><ul><li>Marker in the logic of a base use case indicating where extension is allowed </li></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Example: “Extension points: <step #>: Use case <#> <Use case name> </li></ul></ul></ul></ul></ul><ul><ul><li>In the figure below, the name of the extension is listed in the Extension Points compartment of the base use case </li></ul></ul>
  5. 5. Use Cases <ul><li>“ Inherits” Use Case (realizes Generalization Relationship) In UML modeling, a generalization relationship is a relationship in which one model element (the child) is based on another model element (the parent). </li></ul><ul><ul><li>Generalization relationships are used in use case diagrams (as well as class, component, deployment diagrams) </li></ul></ul><ul><li>“ Inherits” Use Case – “ A generalization relationship between use cases implies that the child use case contains all the attributes, sequences of behavior and extension points defined in the parent use case, and participates in all the relationships of the parent use case” ---- Writing Effective Use Cases, A. Cockburn, 1999 </li></ul>
  6. 6. Use Cases <ul><li>Base Course of Action - “Use the ATM” </li></ul><ul><li>Included Use Case – “Withdraw Cash” </li></ul><ul><ul><li>An arrow goes from the base use case to the included use case, signifying that the base use case &quot;knows about&quot; the included one </li></ul></ul><ul><ul><li>Use the stereotype of <<include>> on a dependency relationship </li></ul></ul><ul><ul><li><<include>> dependency can be viewed as: </li></ul></ul><ul><ul><ul><li>Invocation of a use case by another one </li></ul></ul></ul><ul><ul><ul><ul><li>Same idea of a function call or invoking a method </li></ul></ul></ul></ul><ul><ul><li>Use <<include>> dependencies whenever one use case needs the behavior of another </li></ul></ul>
  7. 7. Use Case diagrams <ul><li>Extending Use Case - “Spell Check” </li></ul><ul><ul><li>Use an arrow going from the extending use case back to the base use case </li></ul></ul><ul><ul><ul><li>Signifies that the extending use case &quot;knows about&quot; the base use case </li></ul></ul></ul><ul><ul><ul><li>The reverse of the &quot;includes&quot; relation. </li></ul></ul></ul>
  8. 8. Use Case diagrams <ul><li>Extending Use Case </li></ul><ul><ul><li>Extension Points - point at which an extending use case is added </li></ul></ul><ul><ul><ul><li>Marker in the logic of a base use case indicating where extension is allowed. (stereotype <<extend>> marks extension use case) </li></ul></ul></ul><ul><ul><li>Why use them? </li></ul></ul><ul><ul><ul><li>Conceptually inserts additional action sequences into the base use-case sequence </li></ul></ul></ul><ul><ul><ul><li>Picks up the course of behavior, and when done, deposits the actor back at the point (extension) in the base use case that got interrupted. </li></ul></ul></ul><ul><ul><ul><li>Just a scenario extension that outgrew the use case in which it was embedded. </li></ul></ul></ul><ul><li>Alistair Cockburn recommends: “Don't use extension use cases, unless you have a really good reason. If you do use them, absolutely don't expose the extension points in the use case diagram.” ---- Writing Effective Use Cases, A. Cockburn, 1999 </li></ul>
  9. 9. Use Case diagrams <ul><li>“ Inherits” Use Case - “Do one transaction” (parent) </li></ul><ul><ul><ul><li>Inheriting use case would completely replace one or more of the scenarios (paths) of the “parent” use case </li></ul></ul></ul><ul><ul><ul><li>Good test phrases for any &quot;generalized&quot; concept is &quot;generic&quot; or &quot;some kind of&quot;. </li></ul></ul></ul><ul><ul><ul><li>If you find yourself describing a generic interaction (or actor), then you have a candidate for &quot;generalizes”; “inheritance” principle </li></ul></ul></ul>
  10. 10. Use Case diagrams <ul><li>System Boundary - Usual to display use cases as being inside the system and actors as being outside the (ATM) system. </li></ul>
  11. 11. Use Case Guidelines (by Alistair Cockburn) <ul><li>Reminders </li></ul><ul><ul><li>Write something readable </li></ul></ul><ul><ul><ul><li>Casual, readable use cases are still useful, whereas unreadable use cases won't get read </li></ul></ul></ul><ul><li>Work breadth-first, from lower precision to higher precision </li></ul><ul><ul><li>Precision Level 1: Primary actor's name and goal </li></ul></ul><ul><ul><li>Precision Level 2: The use case brief, or the main success scenario </li></ul></ul><ul><ul><li>Precision Level 3: The extension conditions </li></ul></ul><ul><ul><li>Precision Level 4: The extension handling steps </li></ul></ul><ul><li>For each step </li></ul><ul><ul><li>Show a goal succeeding </li></ul></ul><ul><ul><li>Capture the actor's intention , not the user interface details </li></ul></ul><ul><ul><li>Have an actor pass information , validate a condition , or update state </li></ul></ul><ul><ul><li>Write between-step commentary to indicate step sequencing (or lack of) </li></ul></ul><ul><ul><li>Ask &quot;why&quot; to find a next-higher level goal (lower precision) </li></ul></ul>
  12. 12. Use Case Guidelines (by Alistair Cockburn) <ul><li>For data descriptions: </li></ul><ul><ul><li>Precision Level 1: Data nickname </li></ul></ul><ul><ul><li>Precision Level 2: Data fields associated with the nickname </li></ul></ul><ul><ul><li>Precision Level 3: Field types, lengths, and validations </li></ul></ul>
  13. 13. Use Case Writing Process (by Alistair Cockburn) <ul><li>Name the system scope </li></ul><ul><li>Brainstorm and list the primary actors </li></ul><ul><ul><li>Find every human and non-human primary actor, over the life of the system </li></ul></ul><ul><li>Brainstorm and exhaustively list user goals for the system </li></ul><ul><li>Select one use case to expand </li></ul><ul><ul><li>Consider writing a narrative to learn the material </li></ul></ul><ul><li>Write the main success scenario (MSS) </li></ul><ul><ul><li>Use 3 to 9 steps to meet all interests and guarantees </li></ul></ul><ul><li>Brainstorm and exhaustively list the extension conditions </li></ul><ul><ul><li>Include all that the system can detect and must handle </li></ul></ul><ul><li>Write the extension-handling steps </li></ul><ul><ul><li>Each will end back in the MSS, at a separate success exit, or in failure </li></ul></ul><ul><li>Extract complex flows to sub use cases; merge trivial sub use cases </li></ul><ul><ul><li>Extracting a sub use case is easy, but it adds cost to the project </li></ul></ul><ul><li>Readjust the set: Add, Subtract, Merge, as needed </li></ul>
  14. 14. <ul><li>Questions? </li></ul>Use Case diagrams
  15. 15. A little Quiz!  <ul><li>Q1. The “Use Case Model” captures the requirements of a system, by communicating with users and other stakeholders in (choose best answer): </li></ul><ul><ul><li>How the system is supposed to work. </li></ul></ul><ul><ul><li>What the system will do for the users. </li></ul></ul><ul><ul><li>What the system will do for stakeholders. </li></ul></ul><ul><ul><li>What the system is intended to do. </li></ul></ul><ul><li>Q2. In regards to <include> use cases, use <<include>> dependencies whenever one use case needs the ______ of another. </li></ul><ul><li>Q3. Think of an <<include>> dependency as an ________ of a use case by another one – same idea of a function call or invoking a method: </li></ul><ul><ul><li>Inclination </li></ul></ul><ul><ul><li>Intoxication </li></ul></ul><ul><ul><li>Invocation </li></ul></ul><ul><ul><li>Annihilation </li></ul></ul><ul><li>Q4. In regards to <<extends>> use cases, one use case may be used to _______ the behavior of another. </li></ul><ul><li>Q5. In regards to “inheriting” use cases, the inheriting use case would completely _______ one or more of the courses of action of the inherited use case. </li></ul><ul><li>Q6. In regards to a System Boundary, it is usual to display use cases as being _______ the system and actors as being _______ the system. </li></ul><ul><li>Q7. An extending use case, conceptually inserts additional action ________ into the ________ use-case sequence </li></ul><ul><li>Q8. “Spell Check” is an example of what type of use case? </li></ul><ul><li>Q9. “Withdraw Cash” is an example of what type of use case? </li></ul><ul><li>Q10. For each use case step: Capture the actor’s __________, not the user interface details. </li></ul><ul><li>Q11. When writing the main success scenario (MSS), use 3 to 9 steps to meet all ________ and _________. </li></ul>
  16. 16. Quiz Answers! <ul><li>Q1. The “Use Case Model” captures the requirements of a system, by communicating with users and other stakeholders in (choose best answer): </li></ul><ul><ul><li>How the system is supposed to work. </li></ul></ul><ul><ul><li>What the system will do for the users. </li></ul></ul><ul><ul><li>What the system will do for stakeholders. </li></ul></ul><ul><ul><li>What the system is intended to do. </li></ul></ul><ul><li>Q2. In regards to <include> use cases, use <<include>> dependencies whenever one use case needs the _ behavior _ of another. </li></ul><ul><li>Q3. Think of an <<include>> dependency as an ________ of a use case by another one – same idea of a function call or invoking a method: </li></ul><ul><ul><li>Inclination </li></ul></ul><ul><ul><li>Intoxication </li></ul></ul><ul><ul><li>Invocation </li></ul></ul><ul><ul><li>Annihilation </li></ul></ul><ul><li>Q4. In regards to <<extends>> use cases, one use case may be used to __ extend __ the behavior of another. </li></ul><ul><li>Q5. In regards to “inheriting” use cases, the inheriting use case would completely __ replace __ one or more of the courses of action of the inherited use case. </li></ul><ul><li>Q6. In regards to a System Boundary, it is usual to display use cases as being _ inside _ the system and actors as being _ outside _ the system. </li></ul><ul><li>Q7. An extending use case, conceptually inserts additional action _ sequences _ into the _ base _ use-case sequence </li></ul><ul><li>Q8. “Spell Check” is an example of what type of use case? Extends </li></ul><ul><li>Q9. “Withdraw Cash” is an example of what type of use case? Inherits or Includes </li></ul><ul><li>Q10. For each use case step: Capture the actor’s _ intention _, not the user interface details. </li></ul><ul><li>Q11. When writing the main success scenario (MSS), use 3 to 9 steps to meet all _ interests _ and _ guarantees _. </li></ul>

×