32
Specifying Requirements with Use Case Diagrams

with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

Embed Size (px)

Citation preview

Page 1: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

Specifying Requirements with Use Case Diagrams

Page 2: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

OUTLINE Introduction Use Case Diagrams Writing Use Cases Guidelines for Effective Use Cases

Page 3: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

SOURCE OF REQUIREMENTS Initial requirements come from the customer, by:

• Documents, Meetings, reports

Advanced requirements come from the analysts, after studying:

• Scope and price • Feasibility (technological, organizational etc) • Prototypes

Final requirements are stabilized in an iterative process.

Introduction | Diagrams | Writing | Guidelines

Page 4: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

REQUIREMENTS VS. DESIGN

Requirements: • What the system should

do • More abstract

Design:

• How the system should do it

• More detailed

Introduction | Diagrams | Writing | Guidelines

Page 5: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

TYPES OF REQUIREMENTS Visible Functional Requirements

• “The system will deliver cash to the customer”

• “Cash will be delivered after card was taken out”

Qualitative Requirements • “The authorization process will take no

more than 1 sec” Hidden Requirements

• “Database maintenance processes will occur every night”

Qualitative Requirements

Hidden Functional

Requirements

Functional Visible

Requirements

Introduction | Diagrams | Writing | Guidelines

Page 6: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

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

Introduction | Diagrams | Writing | Guidelines

Page 7: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

USE CASE DIAGRAM OBJECTIVE

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

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

Introduction | Diagrams | Writing | Guidelines

Page 8: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

WHAT MAKES GOOD USE-CASE SPECIFICATION?

Lack of ambiguity • Each requirement must be interpreted in a single manner.

Completeness • The collection of all use cases is everything that can be done

to/with the system. Consistency

• Requirements should not conflict with each other. If there are, tradeoffs must be detected and discussed.

Avoid design • Requirements should raise a need, not answer it.

Introduction | Diagrams | Writing | Guidelines

Page 9: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

USE CASES AS MEANS OF COMMUNICATION

The use case should stimulate a discussion about what the system should do, mainly with people who are outside of the development team.

Introduction | Diagrams | Writing | Guidelines

Customers Designers Users

Page 10: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

OUTLINE Introduction Use Case Diagrams Writing Use Cases Guidelines for Effective Use Cases

Page 11: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

Example

A SIMPLE EXAMPLE

Handle Message

Cellular Phone

Customer

Bill Management

Handle CallExternal Phone

Company

Actors Use Case System

boundary

Introduction | Diagrams | Writing | Guidelines

Association

Page 12: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

FINDING ACTORS External objects that produce/consume data:

• Must serve as sources and destinations for data • Must be external to the system

Humans Machines External systems

Sensors Organizational Units

Introduction | Diagrams | Writing | Guidelines

Page 13: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

Example

ACTORS CAN BE GENERALIZED The child actor inherits all use-cases associations

Introduction | Diagrams | Writing | Guidelines

Should be used if (and only if), the specific actor has more responsibility than the generalized one (i.e., associated with more use-cases)

Register ClientSales Person

Institutional Sales Person

Perform Sale

Perform Business Sale

Sales Manager

Cancel Sale

Page 14: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

LINKING USE-CASES

Linking enables flexibility in requirements specification • Isolating functionality • Enabling functionality sharing • Breaking functionality into manageable chunks

Three mechanism are used:

• Include • Extend • Inheritance

Introduction | Diagrams | Writing | Guidelines

Page 15: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

USE-CASE LEVELS

User goals

Perform Sale

Choose Products

Fill-in billing info

Sub-functionality

Introduction | Diagrams | Writing | Guidelines

Base Use Case: Used directly by the user

Alistair Cockburn “Writing Effective Use Cases”

Page 16: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

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.

Introduction | Diagrams | Writing | Guidelines

Perform Sale

Fill-in billing info

<<include>>

Example

Page 17: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

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

Introduction | Diagrams | Writing | Guidelines

Perform Sale After checkout

Gift wrap Products

<<extend>> Product is a gift

Example

Page 18: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

EXAMPLE: AMAZON

Product Page

Review Writing

Shopping Cart

Introduction | Diagrams | Writing | Guidelines

Page 19: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

EXAMPLE – CONT’D

Introduction | Diagrams | Writing | Guidelines

Search Product

Navigate Deals

Checkout

Handle Order Status

Login Register

View Product Details

Write Revie

w

Rank Supplier «include»

«include»

«include»

«include»

«extend» user is not a member

«extend»

«extend»

After page generation

Add to cart

«extend»

Customer

Page 20: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

GENERALIZATION BETWEEN USE-CASES

The child use case inherits the behavior parent use case: • The interaction (described in the textual description) • Use case links (associations, include, extend, generalization)

Child use-case can substitute parent Use case Overriding occurs through the textual description

Introduction | Diagrams | Writing | Guidelines

Example

Handle Sale Call

Customer Representative

Tech Assistant Representative

Handle Call

Handle Technical Assistance Call

1. Transfer call to available representative2. Mark representative as busy3. Start record call4. Stop record call 5. Log call details6. Mark representative as free

Page 21: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

GENERALIZATION HAZARDS Combining generalizations of actors and use-cases can be dangerous

Undergrad Student

Graduate Student

Submit Exam

Submit Thesis

Undergrad Student

Graduate Student

Submit and Get Grade

Submit Thesis

Submit Exam

Bad: Undergrad can submit thesis

Good: Only graduate student can submit thesis

Introduction | Diagrams | Writing | Guidelines

Page 22: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

EXAMPLE: EASTERN STATE UNIVERSITY (ESU) REGISTRATION SYSTEM.

1. Professors indicate which courses they will teach on-line.

2. A course catalog can be printed 3. Allow students to select on-line four courses for

upcoming semester. 4. No course may have more than 10 students or less

than 3 students. 5. When the registration is completed, the system sends

information to the billing system. 6. Professors can obtain course rosters on-line. 7. Students can add or drop classes on-line.

Introduction | Diagrams | Writing | Guidelines

Page 23: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

Introduction | Diagrams | Writing | Guidelines

EXAMPLE: EASTERN STATE UNIVERSITY (ESU) REGISTRATION SYSTEM.

Page 24: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

OUTLINE

Introduction Use Case Diagrams Writing Use Cases Guidelines for Effective Use Cases

Page 25: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

OUTLINE Introduction Use Case Diagrams Writing Use Cases Guidelines for Effective Use Cases

Page 26: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

HOW TO MODEL?

print

save Bullets format

load Save

as

preview

File action

s

Formatting actions

Viewing Actions

Font forma

t

Paragraph format

Bottom-up Process Top-down Process

Starting with throwing all scenarios on the page, and then combining them:

Starting with an overview of the system, and then splitting Use-cases

Page 27: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

HOW TO MODEL – CONT’D

Most of the analysis process are actually

Combined

Page 28: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

COMBINING PROCESSES Number Limit:

• The diagram should have between 3 to 10 base use-case. No more than 15 use cases (base + included + extending).

Abstraction: • All use-cases should be in similar abstraction levels.

Size: • Use cases should be described in half a page or more.

Interaction: • Use-cases which are carried out as part of the same interaction.

UC UC UC

Introduction | Diagrams | Writing | Guidelines

Page 29: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

DIVIDING PROCESSES Size:

• If a use-cases takes more than a page, consider include/extend

Weak dependency: • If the dependency between two parts of a use-case is weak,

they should be divided. UC

Introduction | Diagrams | Writing | Guidelines

Page 30: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

MORE GUIDELINES Factor out common usages that are required by multiple use cases

• If the usage is required use <<include>> • If the base use case is complete and the usage may be

optional, consider use <<extend>> A use case diagram should:

• contain only use cases at the same level of abstraction • include only actors who are required

Introduction | Diagrams | Writing | Guidelines

Page 31: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

WHEN ARE WE DONE?

When every actor is specified. When every functional requirement has a use-case which satisfies it. A tractability matrix can help us determine it:

Use Cases

Requirements

Introduction | Diagrams | Writing | Guidelines

Page 32: with Use Case Diagrams - Drexel Universityyfcai/CS451/slides/UML-Use Case Diagra… · OUTLINE . Introduction . Use Case Diagrams . Writing Use Cases . Guidelines for Effective Use

SUMMARY Introduction

to the Unified Modeling Language (UML) To Use Case Diagram

Use Case Diagrams Dual presentation of use-cases Include, Extend, Inheritance

Writing Use Cases Preconditions & Post-conditions Main scenario vs. Alternative Flow

Guidelines for Effective Use Cases