use-cases. outline introduction use case diagrams writing use cases

27
Use-Cases

Upload: wade-figge

Post on 31-Mar-2015

250 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Use-Cases

Page 2: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Outline

• Introduction

• Use Case Diagrams

• Writing Use Cases

Page 3: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Illustration

Use Cases

• A use case is a contract of an interaction between the system and an actor.

• A full use-case model comprise of:– A diagram, describing relations between use-cases

and actors.

– A document describing the use case in details

Register User

Use case in diagram Use Case in script

admin

Page 4: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Use Case Diagram Objective

1. Create a semi-formal model of the functional requirements

2. Analyze and define:– Scope– External interfaces– Scenarios and reactions

Page 5: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Outline

• Introduction

• Use Case Diagrams

• Writing Use Cases

• Guidelines for Effective Use Cases

Page 6: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

What’s in a Use Case Model?Use Case Diagram

Actor Use Case

ActorSomeone or something outside the system acting in a role that interacts with the system. Could be a human or another system.

Use CaseDefines a sequence of actionsperformed by a system that yields an observable result of value to the actor

Page 7: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Example

A Simple Example

Handle Message

Cellular Phone

Customer

Bill Management

Handle CallExternal Phone

Company

ActorsUse CaseSystem

boundaryAssociation

Page 8: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Project Accounting Consultant

System

Project Manager

Submit Timesheet

Complete Timesheets

Use Case Model: Identify

Use Case NameThe name should be:•Brief•Unique•Written as an active verb•Meaningful

You should be able to tell what the actor wants to achieve in the use case from its name.

Each Actor and Use Case needs a brief description.

ActorBriefly state its role, goals and responsibilities in relation to the system.

Use CaseBriefly summarise what takes place in the use case, giving an indication of its scope.

Example actor:

Name: Consultant

Brief Description: The consultant updates their daily timesheet and expense information and gets status reports.

Example use case:

Name: Submit Timesheet

Brief Description: The consultant enters details of the number of hours worked and the activities worked on, then confirms and submits the timesheet.

Page 9: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Linking Use-Cases

• Three mechanism are used:– Include– Extend– Inheritance

Page 10: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Use-Case Levels

User goals

Perform Sale

Choose Products

Fill-in billing info

Sub-functionality

Base Use Case: Used directly by the user

Alistair Cockburn “Writing Effective Use Cases”

Page 11: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

The “Include” Construct

• Include is used when:– Decomposing complicated behavior– Centralizing common behavior

• The base use case explicitly incorporates the behavior

of another use case at a location specified in the base.

Perform Sale

Fill-in billing info

<<include>>

Example

Page 12: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Extend – Graphical Representation

• The base use case can incorporate another use case at certain points, called extension points.

• Note the direction of the arrow– The base use-case does not know which use-case

extends it

Perform SaleAfter checkout

Gift wrap Products

<<extend>>Product is a gift

Example

Page 13: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Example: Amazon

Product Page

Review Writing

Shopping Cart

Page 14: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Example – cont’d

Search Product

Navigate Deals

Checkout

Handle Order Status

Login Register

View Product Details Write

Review

Rank Supplier«include»

«include»

«include»

«include»

«extend»user is not a member

«extend»

«extend»

After page generation

Add to cart

«extend»

Customer

Page 15: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Outline

• Introduction

• Use Case Diagrams

• Writing Use Cases

• Guidelines for Effective Use Cases

Page 16: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Structure of a Use Case SpecificationName

Actors

Preconditions

Post conditions

Success Scenario

Alternatives flows

Trigger

Page 17: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Triggers

• What starts the use-case?

• Examples:– Customer reports a claim– Customer inserts card– System clock is 10:00pm

Page 18: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Preconditions

• What the system needs to be true before running the use-case.

• Examples– User account exists– User has enough money in her account– There is enough disk space

Page 19: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Post-Conditions

• A post-condition is the outcome of the use-case.

• Examples– Money was transferred to the user account– User is logged in– The file is saved to the hard-disk

Page 20: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Success Scenario

• The success scenario is the main story-line of the use-case

• It is written under the assumption that everything is okay, no errors or problems occur, and it leads directly to the desired outcome of the use-case

• It is composed of a sequence of action steps • Example:

1. Administrator enters course name, code and description

2. System validates course code

3. System adds the course to the db and shows a confirmation message

Interaction step

Validation Step

Internal Change Step

(plus) Interaction Step

Page 21: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Use-Cases – Common Mistakes

• Complex diagram• No system• No actor• Too many user interface details

– “User types ID and password, clicks OK or hits Enter”• Very low goal details

– User provides name– User provides address– User provides telephone number– …

Page 22: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Alternative Flows

Success Scenario

ShortcutsExceptions

Endpoints

• Used to describe exceptional functionality

• Examples:– Errors– Unusual or rare

cases– Failures– Starting points– Endpoints– Shortcuts

Starting points

Page 23: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Alternative Flows - Example

• Errors:– “Case did not eject properly”– “Any network error occurred during steps 4-7”– “Any type of error occurred”

• Unusual or rare cases– “Credit card is defined as stolen”– “User selects to add a new word to the dictionary”

• Endpoints– “The system detects no more open issues”

• Shortcuts:– “The user can leave the use-case by clicking on the “esc”

key

Page 24: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Exercise• I am the manager of a theatre.• I want to create an automated movie ticket machine.• You are analysts who need to describe

what the customer wants as a set of use cases• Simplifying assumptions:

– One movie showing at a time– Movie time is same every day, only one time, same price– Only manager can change/add movie– Customer can only buy tickets

• Who or what are the actors?• What are the use cases (goals of actors)?

Page 25: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Use case diagramfor Movie Ticket Machine

• Why are there three Actors?• Why three use cases for Customer?• Which use cases look easy to write?

Page 26: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Use cases for ManagerUse case: Set titleActors: Manager, Machine1. Manager requests a change of movie title2. Machine asks manager for new movie title3. Manager enters movie title

Use case: Set priceActors: Manager, Machine1. Manager requests a change of ticket price2. Machine asks manager for new price for movie title3. Manager enters ticket priceAlternatives: Invalid priceIf manager enters price below $1 or greater than $103a. Machine asks manager to reenter price

Use case: Set seatsActors: Manager, Machine1. Manager requests a change in number of seats2. Machine asks manager for number of seats in theatre3. Manager enters number of seatsAlternatives: Invalid number of seatsIf manager enters number less than 20 or greater than 9993a. Machine asks manager to reenter number of seats

Page 27: Use-Cases. Outline Introduction Use Case Diagrams Writing Use Cases

Use cases for Customer

Use case: # of ticketsActors: Customer, Machine1. Customer enters number of tickets2. Machine displays total balance dueAlternative: Customer wants zero ticketsAt step 1, customer enters zero tickets1a. Display thank you message1b. Set balance to $0.0

Use case: Return change to customerActors: Customer, Machine1. Customer requests change2. Machine dispenses money3. Machine updates customer balance

Use case: Buy ticketsUse case: Buy ticketsActors: Customer, MachineActors: Customer, Machine1. Customer requests tickets1. Customer requests tickets2. Machine tells customer to put 2. Machine tells customer to put balance due in money slot balance due in money slot3. Customer enters money in money slot3. Customer enters money in money slot4. Machine updates customer balance4. Machine updates customer balance5. Customer requests tickets5. Customer requests tickets6. Machine prints tickets6. Machine prints tickets7. Machine updates number of seats7. Machine updates number of seatsAlternative: Insufficient seatsAlternative: Insufficient seatsAt step 1, if number of tickets requested At step 1, if number of tickets requested is less than available seats, is less than available seats, 1a. Display message and end use case1a. Display message and end use caseAlternative: Insufficient fundsAlternative: Insufficient fundsAt step 5, if money entered < total cost,At step 5, if money entered < total cost,5a. Display insufficient amount entered 5a. Display insufficient amount entered 5b. Go to step 35b. Go to step 3