CSC/ECE 517 Fall 2010/ch4 4a RJ: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
Line 2: Line 2:
== Introduction ==
== Introduction ==
== Use Case Basics ==
== Use Case Basics ==
<p>Use cases can be defined in many ways. There are many formal definitions for it. Very simply put, a use case is a reason to use a system. For example, a student borrowing a book from a library would be a use case of the library or a bank cardholder might need to use an ATM to get cash out of their account. More formally, “a use case is a collection of possible sequences of interactions between the system under discussion and its Users (or Actors), relating to a particular goal” [http://alistair.cockburn.us/Use+case+fundamentals].</p>
<p>A use case is initiated by a user with a particular goal in mind, and completes successfully when that goal is satisfied. The system is treated as a "black box", and the interactions with system, including system responses, are as perceived from outside the system.</p>
<p>Use cases capture who (actor) does what (interaction) with the system, for what purpose (goal), without dealing with system internals. A complete set of use cases specifies all the different ways to use the system, and therefore defines all behavior required of the system, bounding the scope of the system.[http://www.bredemeyer.com/use_cases.htm]</p>
Now let us define some terms used with use cases: [http://en.wikipedia.org/wiki/Use_case]
<ol>
<li><b>Actor:</b> An actor is a type of user that interacts with the system (ex student borrowing book or cardholder using ATM). Actors are also external entities (people or other systems) who interact with the system to achieve a desired goal. The goal must be of value to the actor.</li>
<li><b>Goal:</b> Without a goal a use case is useless. There is no need for a use case when there is no need for any actor to achieve a goal. A goal briefly describes what the user intends to achieve with this use case. For example, the goal of a student using the library is to obtain the book. There is no point in having a use case like “the student enters the library” as that in itself has no value to the actor.</li>
<li><b>Stakeholder:</b> A stakeholder is an individual or department that is affected by the outcome of the use case. Individuals are usually agents of the organization or department for which the use case is being created. A stakeholder might be called on to provide input, feedback, or authorization for the use case. The stakeholder section of the use case can include a brief description of which of these functions the stakeholder is assigned to fulfill.</li>
<li><b>Trigger:</b> A trigger describes the event that causes the use case to be initiated. This event can be external or internal. If the trigger is not a simple true "event" (e.g., the customer presses a button), but instead "when a set of conditions are met", there will need to be a triggering process that continually (or periodically) runs to test whether the "trigger conditions" are met: the "triggering event" is a signal from the trigger process that the conditions are now met.
In our example with the student, a trigger would be the need for the book due to an approaching exam or test which causes the student to go to the library to borrow a book.
</li>
<li><b>Precondition:</b> A precondition defines all the conditions that must be true (i.e., describes the state of the system) for the trigger to meaningfully cause the initiation of the use case. That is, if the system is not in the state described in the preconditions, the behavior of the use case is indeterminate. For example, the student should be a member of the library and have the required identity to borrow a book. If the student is not a member of the library, there is no point in the student trying to borrow a book from that library.</li>
<li><b>Scenarios:</b> A scenario usually specifies when the use case starts and ends. It describes the interaction with actors and shows the flow of events between a user and system. For example, when a student tries to borrow a particular book from the library, it doesn’t always necessarily turn out the same way. Sometimes the book is available and sometimes it is already borrowed by someone else or the library may not have a given book. These are all examples of use case scenarios. The outcome in each case if different depending on circumstances, but they all relate to the same goal that is, they are all triggered by the same need(in this case, need for the book) and all the scenarios have the same starting point.</li>
</ol>
<p>Now that we know something about use cases, let us go ahead and describe a simple use case:</p>
Use Case 1: Request book from the library (automated system).
1.1: Summary/Goal
        To borrow book a particular book from the library
1.2: Actors
        Student
1.3: Preconditions
        Student should be a member of the library and have an id.
1.4: Main Path
        System requests for student ID and checks if he/she is a member
        Student selects “request book”
        Student enters name(s) of the book(s)
        System checks for availability of books and displays results accordingly
        Student confirms the order
        System displays details of where the requested books are stacked
1.5: Alternate Path
        System does not recognize Id or student is not a member. System will not allow any books to be checked out.
        All books requested are already checked out. Displays this information to student and closes request.
<p>The above description shows a very simple use case. However, there are a few essential characteristics to be noticed about the use case:</p>
<ol>
<li>We have identified the key components of a use case, that is, the goal, actors, preconditions, key scenarios/flow and preconditions. It is very essential that we identify these components before writing a use case.</li>
<li>We have not gone into any sort of technical details about implementation or user interface design. Use cases only represent a very high level design. We are only trying to understand the flow and uses of the system.</li>
<li>We have recorded a set of paths (scenarios) that traverse an actor from a trigger event (start of the use case) to the goal (success scenarios).</li>
<li>We have recorded a set of scenarios that traverse an actor from a trigger event toward a goal but fall short of the goal (failure scenarios).</li>
<ol>
== Writing Use Cases ==
== Writing Use Cases ==
<p>Writing Use Cases for a system is a process taken between those designing the system and the Stakeholders.  There are many different ways to write Use Cases [SOURCE].  Because of this, there are many different formats that Use Cases can take when they are written.  There are, however, certain guidelines that should be followed in the process of writing Use Cases.  In general, these guidelines are:</p>
<p>Writing Use Cases for a system is a process taken between those designing the system and the Stakeholders.  There are many different ways to write Use Cases [SOURCE].  Because of this, there are many different formats that Use Cases can take when they are written.  There are, however, certain guidelines that should be followed in the process of writing Use Cases.  In general, these guidelines are:</p>

Revision as of 04:06, 20 October 2010

Use Cases

Introduction

Use Case Basics

Use cases can be defined in many ways. There are many formal definitions for it. Very simply put, a use case is a reason to use a system. For example, a student borrowing a book from a library would be a use case of the library or a bank cardholder might need to use an ATM to get cash out of their account. More formally, “a use case is a collection of possible sequences of interactions between the system under discussion and its Users (or Actors), relating to a particular goal” [1].

A use case is initiated by a user with a particular goal in mind, and completes successfully when that goal is satisfied. The system is treated as a "black box", and the interactions with system, including system responses, are as perceived from outside the system.

Use cases capture who (actor) does what (interaction) with the system, for what purpose (goal), without dealing with system internals. A complete set of use cases specifies all the different ways to use the system, and therefore defines all behavior required of the system, bounding the scope of the system.[2]

Now let us define some terms used with use cases: [3]

  1. Actor: An actor is a type of user that interacts with the system (ex student borrowing book or cardholder using ATM). Actors are also external entities (people or other systems) who interact with the system to achieve a desired goal. The goal must be of value to the actor.
  2. Goal: Without a goal a use case is useless. There is no need for a use case when there is no need for any actor to achieve a goal. A goal briefly describes what the user intends to achieve with this use case. For example, the goal of a student using the library is to obtain the book. There is no point in having a use case like “the student enters the library” as that in itself has no value to the actor.
  3. Stakeholder: A stakeholder is an individual or department that is affected by the outcome of the use case. Individuals are usually agents of the organization or department for which the use case is being created. A stakeholder might be called on to provide input, feedback, or authorization for the use case. The stakeholder section of the use case can include a brief description of which of these functions the stakeholder is assigned to fulfill.
  4. Trigger: A trigger describes the event that causes the use case to be initiated. This event can be external or internal. If the trigger is not a simple true "event" (e.g., the customer presses a button), but instead "when a set of conditions are met", there will need to be a triggering process that continually (or periodically) runs to test whether the "trigger conditions" are met: the "triggering event" is a signal from the trigger process that the conditions are now met. In our example with the student, a trigger would be the need for the book due to an approaching exam or test which causes the student to go to the library to borrow a book.
  5. Precondition: A precondition defines all the conditions that must be true (i.e., describes the state of the system) for the trigger to meaningfully cause the initiation of the use case. That is, if the system is not in the state described in the preconditions, the behavior of the use case is indeterminate. For example, the student should be a member of the library and have the required identity to borrow a book. If the student is not a member of the library, there is no point in the student trying to borrow a book from that library.
  6. Scenarios: A scenario usually specifies when the use case starts and ends. It describes the interaction with actors and shows the flow of events between a user and system. For example, when a student tries to borrow a particular book from the library, it doesn’t always necessarily turn out the same way. Sometimes the book is available and sometimes it is already borrowed by someone else or the library may not have a given book. These are all examples of use case scenarios. The outcome in each case if different depending on circumstances, but they all relate to the same goal that is, they are all triggered by the same need(in this case, need for the book) and all the scenarios have the same starting point.

Now that we know something about use cases, let us go ahead and describe a simple use case:

Use Case 1: Request book from the library (automated system).

1.1: Summary/Goal

       To borrow book a particular book from the library

1.2: Actors

       Student

1.3: Preconditions

       Student should be a member of the library and have an id.

1.4: Main Path

       System requests for student ID and checks if he/she is a member
       Student selects “request book”
       Student enters name(s) of the book(s)
       System checks for availability of books and displays results accordingly
       Student confirms the order
       System displays details of where the requested books are stacked

1.5: Alternate Path

       System does not recognize Id or student is not a member. System will not allow any books to be checked out.
       All books requested are already checked out. Displays this information to student and closes request.

The above description shows a very simple use case. However, there are a few essential characteristics to be noticed about the use case:

  1. We have identified the key components of a use case, that is, the goal, actors, preconditions, key scenarios/flow and preconditions. It is very essential that we identify these components before writing a use case.
  2. We have not gone into any sort of technical details about implementation or user interface design. Use cases only represent a very high level design. We are only trying to understand the flow and uses of the system.
  3. We have recorded a set of paths (scenarios) that traverse an actor from a trigger event (start of the use case) to the goal (success scenarios).
  4. We have recorded a set of scenarios that traverse an actor from a trigger event toward a goal but fall short of the goal (failure scenarios).
    1. Writing Use Cases

      Writing Use Cases for a system is a process taken between those designing the system and the Stakeholders. There are many different ways to write Use Cases [SOURCE]. Because of this, there are many different formats that Use Cases can take when they are written. There are, however, certain guidelines that should be followed in the process of writing Use Cases. In general, these guidelines are:

      1. Never include implementation specific terminology in the Use Case [SOURCE]
      2. Each Use Case should be a set of scenarios, which include different flows of events [SOURCE]

      Iterative Process

      Normally, this process is done iteratively, so that the iterations can build upon each other [SOURCE]. Below is an example of three iterations of the Use Case writing process to illustrate how it can reveal things about a system and layout the functional requirements.

      For this example, we will be creating Use Cases to solve the following problem statement:

      Develop a system to allow users to schedule meetings with each other.
      

      In this system, the stakeholders will be the users of the system. The Users will also be the only Actors in the system.

      Iteration 1

      For the first iteration, we will write out short sentences to describe the functionality that the system will have. Some use cases could be:

      Use Case # Description Actor
      1 Request a Meeting User
      2 Approve a meeting request User
      3 Suggest a new time User
      4 View a User's schedule User

      In this example, the fourth Use Case may not have been an obvious requirement that could be derived from the original problem statement, but in the process of creating the Use Cases, it was discovered that it would be a good requirement for the system to have.

      Iteration 2

      The next iteration would involve writing out longer descriptions for each. This could be done in paragraph form, or by writing a list. Below are the Use Cases in paragraph form:

      Use Case 1 – Request a meeting
      User A chooses the date and time for a meeting with User B.  User A chooses User B as the recipient of the meeting request.
      User A sends the meeting request to User B through the system.
      Use Case 2 – Approve a Meeting Request User A receives a meeting request from User B and accepts the user request. A notification that User A has accepted the meeting is sent to User B.
      Use Case 3 – Suggest a different meeting time User A receives a meeting request from User B and suggests a different time and/or date for the meeting. The response is sent to User B through the system.
      Use Case 4 – View a User's schedule User A would like to schedule a meeting with User B. User A starts the system and opens up User B's schedule. User A can see when User B has already scheduled meetings and User A can then use that information to send User B a meeting request. Use A can also access their own schedule to view when User A has scheduled meetings.

      From writing out the Use Cases with more description, it should become clear that Use Case 2 and Use Case 3 are very similar. In both Use Cases, User A responds to a meeting request and a response/notification is sent to User B. This might lead the designers of the system to combine these two Use Cases into one Use Case for "Respond to Request."

      Iteration 3

      In the next iteration, we're going to use a Use Case template. There are many different Use Case templates, which include different information [SOURCES]. A template can be created that is unique for the system being described, provided each Use Case uses the same template. The template we will use will include:

      Use Case <Number>: Title
      <Number>.1: <Summary/Goal>
      <Number>.2: <Actors>
      <Number>.3: <Preconditions>
      <Number>.4: <Main Path>
      <Number>.5: <Alternate Paths – including sub-flows [S] and error-flows [E]>

      Writing Use Case 1 in this format yields:

      Use Case 1: Request a meeting
      1.1: Summary/Goal User A can choose the date and time for a meeting with User B [Main]. User A can choose User B as the recipient of the meeting request [Main], or multiple Users as the recipient [S.2]. User A sends the meeting request to User B through the system [Main]. Before User A sends the meeting request, User A can opt not to send the request and delete it [S.1]. If User B is no longer in the system, User A receives notification that the meeting request cannot be sent [E.1].
      1.2: Actors Users
      1.3: Preconditions - User A and User B are recorded as Users in the system - User A has logged into the system
      1.4: Main Path 1) User A chooses a date for a meeting 2) User A chooses a time for a meeting 3) User A chooses User B as the recipient for the meeting request 4) User A submits the meeting request 5) User B receives the meeting request the next time User B logs into the system
      1.5: Alternative Path S.1 User A creates a meeting request, but down not submit it. A meeting request is not sent to User B
      S.2 User A creates a meeting request for more than one User. User A submits the meeting request and each User receives it the next time they log in
      E.1 User B is no longer a User in the system. User A receives notification that the meeting request cannot be sent.

      Results

      There are a few interesting things revealed about the system by re-writing the Use Case in this format. The most important is likely that Users will need to "log-in" to the system. This implies that there could be another Actor in the system, namely an Admin. This leads to these additional Use Cases:

      Use Case # Description Actor
      5 Log into the system User
      6 Create a User in the system Admin

      Each of these new Use Cases would then go through the iterations listed above until they are in the template form.

      As you can see from the example, each iteration refines the Use Case and helps to clarify the requirements of the system.

      Use Case Diagrams

      Use Case Diagrams are useful for showing how each component in a system will interact with other components of the system [SOURCE]. They are not good for showing the flow of events that a system will have, like the written Use Cases are [SOURCE]. Also, unlike written Use Cases, Use Case Diagrams use UML so that there is a standard.

      DEFINE UML HERE

      Components of a Use Case Diagram

      UCDs have only 4 major elements: The actors that the system you are describing interacts with, the system itself, the use cases, or services, that the system knows how to perform, and the lines that represent relationships between these elements.[SOURCE: http://www.andrew.cmu.edu/course/90-754/umlucdfaq.html#uses – DIRECT QUOTE]

      Actors in Use Case Diagrams are represented by stick figures:

      Use Cases are represented by ovals:

      Relationships are represented by Solid Lines. Sometimes, arrowheads are added to the lines to indicate the direction of the invocation, or to show which actor is the primary actor [SOURCE: http://www.agilemodeling.com/artifacts/useCaseDiagram.htm]

      Two special relationships that can be shown in a Use Case Diagram are the Extends and Includes relationships. These relationships are usually shown with a dotted line with an arrowhead and <<extend>> or <<include>> written near the line.

      The Extends relationship is used to show when Use Case X is a special case of Use Case Y [SOURCE]. In this situation, the dotted line is drawn from Use Case X to Use Case Y with the arrowhead pointing to Use Case Y.

      The Includes/Uses relationship is used to show that every time Use Case X is done, Use Case Y must also be done [SOURCE]. In this case, the arrow points to Use Case Y.

      Creating a Use Case Diagram

      A Use Case Diagram for the same system described in the Writing a Use Case might look something like:

      As you can see, "Accept Meeting" and "Suggest new time" are special cases of "Respond to request". Also, from this diagram, the system designers are saying that in order to "Request a Meeting" the user must "View Schedule".

      Advanced Topics

      Tools and Examples

      Tools

      There are many different tools available to create Use Cases. For a more comprehensive list, go to Wikipedia's list of UML modeling tools. A sampling are below:

      Examples

      There are many different examples of Use Cases. Some are listed below:

      Further Reading

      References