Sei sulla pagina 1di 70

Use Case Diagrams

Based on Chapter 6: Section 6.6-6.8 Bennett, McRobb and Farmer Object Oriented Systems Analysis and Design Using UML 4th Edition, McGraw Hill, 2010
2010 Bennett, McRobb and Farmer 1

Last Lecture
What is a model? A simplified representation that helps us understand something more complicated, e.g., a tube map

Different types of models used to provide different views of same system, e.g., a person is modelled by a photo, an x-ray, a model of preferences Models range in level of detail: As IS development proceeds, models become more detailed
Diagrams are standardized visual representations used to communicate models. Many diagrams can serve to convey a single model, e.g. a model of a solar system may be conveyed with many diagrams.
2

Size of Real IT Systems


Why model Information Systems? Student programs typically less than 500 lines (first year) up to 5000 lines of Java in following years. Commercial systems may be written by large teams of programmers and may contain 100,000- millions, of lines of code.
3

Many types of models in UML


Activity diagrams Use Case Diagrams Class Diagrams Collaboration Diagrams There are ~14 types of diagrams in UML All types of diagrams vary in detail as project processes, e.g., Use Case Diagram ranges from simple to more complex. UML is for Object-oriented systems development (vs. structured systems approach)
4

Two general types of UML diagrams


Diagrams that support : Structural (static) view: represent things that must be present in the system, e.g., static structure such as objects, attributes, operations and relationships. Behavioural (dynamic) view: represents dynamic behaviour of the system, e.g., showing collaborations among objects and changes to the internal states of objects.
5

The different types of UML diagrams

In this module we will cover:

In this module we will cover:

A model usually consists of many diagrams of different types


8

A model consists of many diagrams of different types


Analysis Model Use Case Model
Campaign Management Assign staff to work on a campaign include Campaign Management Find campaign Assign staff to work on a campaign include include Add a new advert to Find campaign a campaign include include Campaign Add a new Manager advert to a campaign include Check campaign budget

Requirements List

Campaign Manager Check campaign budget extend extend

Class diagram (initial draft)

Interface Prototypes

extend

extend

Print campaign summary

Print campaign invoice

Use Cases

Accountant Print campaign summary

Print campaign invoice

Accountant

Glossary

Use Case Diagrams One View of the Use Case Model

10

In this lecture you will learn


Using scenarios to capture functional requirements Use case diagram
The notation of use case diagrams How to draw use case diagrams How to write use case descriptions

Requirements lists
How prototyping can be used with use case modelling
11

Drawing Use Case Diagrams


Purpose
document the functionality of the system from the users perspective document the scope of the system document the interaction between the users and the system using supporting use case descriptions (behaviour specifications)

12

Notation of Use Case Diagrams


Communication association Use case

Change a client contact


Staff Contact

Actor

System or subsystem boundary (Subject)


13

Requirements as Scenarios

2010 Bennett, McRobb and Farmer

14

What is a Scenario?
Possible interaction between a system and its users Specific scenario
specific data values at each step in the interaction test case

Generalised scenario
cover many specific scenarios

Word scenario most often means specific scenario


15

Mrs H wants to register a new student for Computer Science Mrs H enters the student details
A. Patel lives at 29 Devon Lane, Surbiton

Specific Scenario

Mrs H enters the registration details


home student, G500, first year, adviser Prof Robinson

The system
allocates A. Patel student id 123456789 records A. Patels registration details prints A. Patels course registration form, with the first year G500 recommended programme
16

Generalised Scenario
Administrator wants to enter a student registration Administrator enters the student details
name, address

Administrator enters the course details


fees level, UCAS code, year of study, adviser

The system
generates a student id number records details of the student prints the course registration form, with the recommended programme, if any
17

Essential v. Real Scenarios


Use cases range in level of detail specified, can range from essential to real Essential scenario (minimal detail)
abstract, ignore user interface, ignores precise number of steps, free of technology and design assumptions and user interface details Only contains essential information

Real scenario (maximum detail).


how is the interaction achieved? details of the user interface specifies concrete steps that assume technology and design commitments
18

Essential v. Real Scenarios


Essential
Administrator enters the course details
UCAS code

Real
Administrator chooses the UCAS course code form a drop-down box, with an others option which allows the course code and the description
19

Use Cases
Generalised and essential scenarios Number of use cases
up to 80 for complex systems 20 to 50 for most systems

Diagram
very simple and abstract standardised in UML

Description
structured text, not standardised
20

Use Case Diagram


actor use case

Assign staff contact Add new staff member

Campaign Manager

Accountant

communication association
21

Notation of Use Case Diagrams


An actor is
user of the system initiates the interaction Drawn with a stick figure
Campaign Manager

Not all actors are people


can be a connected system (e.g. Facebook)
Invoicing system

22

Case Study: Agate


(from Object-Oriented Systems Analysis and
Design; Bennett, McRobb and Farmer)

2010 Bennett, McRobb and Farmer

23

Agate Organisation
Agate Ltd Board of Directors Administration Accounts Accountant Credit Controller
Accounts Clerks

Creative Account Managers x 4 Graphics Designers


Copy Writers

Computing

Purchasing Assistant

Editors Photographers Resource Librarian

24

Existing system:

Existing and Proposed Systems

client management
record names assign client contact campaign

staff management
names, grades, bonuses

Redevelop existing system in Java, more functions


25

Organisations roles may inform choice of actors


Agate Ltd Board of Directors Administration Accounts Accountant Credit Controller
Accounts Clerks

Creative Account Managers x 4 Graphics Designers


Copy Writers

Computing

Purchasing Assistant

Editors Photographers Resource Librarian

The roles in organization give you an idea for possible actors in your use case scenario. Whom you choose to be an actor may be a specific job title, Accountant, or can be general Creative staff.
26

Notation of Use Case Diagrams


Use cases
Add a new client Assign staff to work on campaign Add a new campaign

drawn as ellipses with a name in or below each ellipse describe a sequence of actions that the system performs to achieve an observable result of value to an actor the name is usually an active verb and a noun phrase
27

Notation of Use Case Diagrams


Communication associations
Add a new client Add a new campaign Campaign Manager Assign staff to work on campaign

line drawn between an actor and a use case represent communication link between an instance of the use case and an instance of the actor

28

Notation of Use Case Diagrams


Subsystems (also called subjects)
drawn as a rectangle around a group of use cases that belong to the same subject in a CASE tool, use cases for different subjects are usually placed in separate use case diagrams
Add a new client Add a new campaign Campaign Manager Assign staff to work on campaign
29

Examples

2010 Bennett, McRobb and Farmer

30

Use case diagrams for Agate

Add a new client Add a new campaign

Campaign Manager

Assign staff to work on campaign

Add a new advert to a campaign


Record completion of a campaign Assign a staff contact Change a client contact

Staff Contact

Record completion of an advert


31

Additional descriptions/notations
Each use case (ellipse) and actor (stick figure) is usually accompanied by a textual actor and use case description. This can be brief description, or can be a step-by-step breakdown of the interaction between the actor and system These descriptions are added using the program you are using to draw UML diagrams

32

Use Case Diagrams will often be accompanied by more detailed descriptions of actor and use case
Campaign Manager Add new advert to campaign

So for above Use Case, additional screens in CASE tool will show the following descriptions:

Campaign Manager

Add new advert to campaign

Detailed description

Detailed description

33

Actor Description
Campaign Manager

Add new advert to campaign

Campaign Manager A Campaign manager is either a Director or an Account Manager. They are responsible for estimating the campaign cost and agreeing it with the client. They are responsible for assigning staff to the team and supervising their work, managing the progress of the campaign, conducting any further budget negotiations, and authorizing the final invoice.
34

Agate Use Cases and Descriptions


Add a new advert to a campaign Record completion of a campaign Assign a staff contact Change a client contact A campaign can consist of many adverts. Details of each advert are entered into the system, including advert cost When a campaign is completed, the actual completion date and cost are entered. A record of completion form is printed out for the Accountant as the basis for invoicing the client Clients have a member of staff assigned to them as their particular contact person. Records when the client s contact person with Agate is changed.

35

Agate Use Cases


Record completion of an advert Add a new client When an advert is completed, the actual date is entered. When Agate obtains a new client, the full details of the client are entered. Typically this will be because of a new campaign, and therefore the new campaign will be added straight away.

Add a new campaign

Assign staff to work on a campaign

When Agate gets the business for a new campaign, details of the campaign are entered, including the intended finish date and the estimated cost. The manager for that campaign is the person who enters it. When a new campaign starts, members of staff are assigned to work on it.

36

Add a new member of staff

Add a new staff grade

Accountant

Change the rate for a staff grade

Change the grade for a member of staff

Record client payment


37

Accountant Use Case descriptions


Add a new member of staff When a new member of staff joins Agate, his or her details are recorded. He or she is assigned a staff number, and the start date is entered. Start date defaults to today s date. The starting grade is entered.

38

Accountant Use Case descriptions


Add a new staff grade Change the rate for a staff grade Change the grade for member of staff Record client payment

39

Accountant Use Case descriptions


Add a new staff grade Occasionally a new grade for a member of staff must be added. The name of the grade is entered. At the same time, the rate for that grade and the rate start date are entered; the date defaults to today s date. Change the rate for a staff grade Annually the rates for grades are changed. The new rate for each grade is entered, and the rate start date set (no default). The old grade is retrieved and the rate finish date for that grade rate set to the day before the start of the new rate.

40

Accountant Use Cases


Change the grade for a member of staff When a member of staff is promoted, the new grade and the date on which they start on that grade are entered. The old staff grade is retrieved and the finish date set to the day before the start of the new one.

Record client payment. When a client pays for a campaign, the payment amount is checked against the actual cost and the date paid is entered.

41

Good Use Cases


Identifying use cases
do not distinguish too many, especially at first

Title
verb and noun combination

Language
user language, not computer-speak avoid click, input, menu box
42

Detailed Description of a Use Case


add more detail structured description following a template
2010 Bennett, McRobb and Farmer 43

Normal Flow
Normal flow (or path)
steps of the interaction distinguish between the users request and the systems response

request

actor

response

system
44

Another version of Use Case description

Campaign Manager

Add new advert to campaign

Use case description: Add a New Advert to a Campaign Actor Action 1. Campaign manager checks campaign budget. System Response 2. Displays campaign budget, total cost of adverts paid for and total estimated cost of adverts not paid for. Creates new advert and adds to list of adverts for that campaign.

3.

Campaign manager enters details of advert including estimated cost.

4.

Alternative Courses Step 4. The advert will exceed the budget and a budget extension request is generated.
45

In comparison: A more general Use Case description. Use cases get more detailed as analysis progresses

Campaign Manager

Add new advert to campaign

Use case description: Add a New Advert to a Campaign

A campaign can consist of many adverts. Details of each advert are entered into the system, including advert cost

46

Additional descriptions for use cases: Alternative Flow


Variation to some steps of the normal flow Alternative flow allows several related scenarios to be combined
Admin. enters the student details Admin updates the student details

Single use case:

admin enters/updates student details


47

Additional descriptions for use cases: Exceptions


Errors, and what happens when they occurs Exceptions v. Alternatives
exception is abnormal alternative is just different to the normal interaction an alternative path could be a separate Use Case

Caution
some versions of Use Cases dont have exceptions dont have too many exceptions
48

Additional descriptions for use cases: Pre- and Postconditions


Precondition
must be true, otherwise the interaction is not possible

Postcondition
how the system is changed by the interaction applies to all alternatives e.g. customer order is recorded

49

Suggested Detailed Use Case Description Template


Use case name Description Precondition: required starting state of system (optional) Normal flow of events (actions and system responses) Alternative flows (optional) Postcondition: ending state of system (optional) Exceptions (optional)
50

Suggested Detailed Use Case Description Template


Use case name Description Precondition: required starting state of system (optional) Normal flow of events (actions and system responses) Alternative flows (optional) Postcondition: ending state of system (optional) Exceptions (optional)
Difference between exceptions and alternative flows is subtle, you will not be required to distinguish these in exams 51

Good Use Cases


Distinguish
user actions system response

Use user language


avoid click, input, menu box, database

For analysis:
abstract as possible avoid user interface details
53

Additional Use Case notations: include and extend


2010 Bennett, McRobb and Farmer 54

Notation of Use Case Diagrams


Dependencies
Extend and Include relationships between use cases shown as stereotyped dependencies stereotypes are written as text strings in guillemets: extend and include

55

include
Common steps can be included in other use cases Common steps documented as a normal use case Referenced by name in using use case
A
include

Common Sequence
include B

56

include
Assign staff to Work on a Campaign

includes

Find Campaign
Campaign Manager Add a New Advert to a Campaign includes

57

Detailing include
Use case: Update widget details Description: Update the details about the widget Normal flow: 1. Widget details are displayed with Find Widget Details 2. User enters new widget price 3. ..

Informal approach not too much apparatus


Use case: Find Widget Details Description: Display the basic details about the widget Normal flow: 1. User requests list of widgets 2. System displays the available widgets 3. User chooses the widget identifier 4. System displays widget details

Possible template for included use case

58

extend
Basic Use Case Extension Point

extend

extend

Extension A

Extension B

One use can extend the functionality of another Extension may be available to another actor
59

Detailing extend
Use case: Display details Description: Display the basic details Normal flow: 1. User enters widget name 2. System displays the details Extension points: When the system displays details (step 2): Print details Confidential display

Informal approach not too much apparatus


Use case: Confidential display Description: Display the basic details Normal flow: Extends Display details 1. User enters authorisation code 2. System displays confidential data

Possible template for extended use case


60

extends
Check Campaign Budget
System Displays Balance

Campaign Manager

extends

extends

Accountant

Print Campaign Summary

Print Campaign Invoice

61

Actor Generalisation
Some actors represent roles which generalise another role Use cases available to the Staff Member are also available to the Campaign Manager

Staff Member

Campaign Manager

Staff Contact
62

Developing Use Cases

2010 Bennett, McRobb and Farmer

63

Use Case Iterations


Use cases can be developed in stages Step 1: Scope identify actors and use cases, short descriptions objective is to scope system Step 2: Details detailed descriptions break out some detailed use cases Step 3: Structure structure use cases using extend and include select the use cases that are to be implemented, discard non-essential functionality

64

Other Uses of Scenarios


Scenario as a test case
test cases derived from use cases

Development increments
implement, test & deliver sets of use cases

Scenarios can be used to analyse other models


we will see the how scenarios analyse an object model, using sequence diagrams

65

Use Case Descriptions


Many projects use templates
name of use case pre-conditions post-conditions purpose description alternative courses errors

66

Drawing Use Case Diagrams


Identify the actors and the use cases Prioritize the use cases Develop each use case, starting with the priority ones, writing a description for each Add structure to the use case model: generalization, include and extend relationships and subsystems

67

Prototyping
Use case modelling can be supported with prototyping Prototypes can be used to help elicit requirements Prototypes can be used to test out system architectures based on the use cases in order to meet the non-functional requirements

68

Prototyping
For user interface prototypes, storyboarding can be used with handdrawn designs

69

Prototyping
User interface prototypes can be implemented using languages other than the one that the system will be developed in
Campaign Selection Holborn Motors Lynch Properties Yellow Partridge Zeta Systems Campaign Selection Campaign Selection Holborn Motors Lynch Properties Yellow Partridge Zeta Systems Spring Jewellery Campaign 2003 Spring Jewellery Campaign 2004 Spring Jewellery Campaign 2005 Summer Collection 2004 OK Quit Client: Client: Client: Holborn Motors Lynch Properties Yellow Partridge Zeta Systems Spring Jewellery Campaign 2003 Spring Jewellery Campaign 2004 Spring Jewellery Campaign 2002 Spring Jewellery Campaign 2005 Summer Collection 2004 OK Quit

Campaign:

Campaign:

Campaign:

OK

Quit

Dialogue initialized.

User selects Client. Campaigns listed.

User selects Campaign.

70

Summary
In this lecture you have learned about: The purpose of use case diagrams The notation of use case diagrams How to draw use case diagrams How to write use case descriptions How prototyping can be used with use case modelling
71

Potrebbero piacerti anche