+ All Categories
Home > Education > Lecture 2 use case diagram-part1

Lecture 2 use case diagram-part1

Date post: 21-Jul-2015
Category:
Upload: ramakant-soni
View: 57 times
Download: 1 times
Share this document with a friend
43
Duration: 3 Hrs 1 Ramakant Soni Assistant Professor Dept. of Computer Science B K Birla Institute of Engineering & Technology, Pilani, India Ramakant Soni @ BKBIET Pilani
Transcript
Page 1: Lecture 2   use case diagram-part1

Duration: 3 Hrs

1

Ramakant SoniAssistant Professor

Dept. of Computer Science

B K Birla Institute of Engineering & Technology, Pilani, India

Ramakant Soni @ BKBIET Pilani

Page 2: Lecture 2   use case diagram-part1

Use case diagrams are used to visualize,specify, construct, and document the(intended) behavior of the system, duringrequirements capture and analysis.

2

Provide a way for developers, domain expertsand end-users to Communicate.

Serve as basis for testing.

Use case diagrams contain use cases, actors,and their relationships.

Ramakant Soni @ BKBIET Pilani

Page 3: Lecture 2   use case diagram-part1

Use cases specify desired behavior.

A use case is a description of a set of

name

3

A use case is a description of a set ofsequences of actions, including variants,a system performs to yield an observableresult of value to an actor.

Each sequence represent an interactionof actors with the system.

Ramakant Soni @ BKBIET Pilani

Page 4: Lecture 2   use case diagram-part1

Describing the flow of events within the usecase.

Can be done in natural language, formal

4

Can be done in natural language, formallanguage or pseudo-code.

Includes: how and when the use case startsand ends; when the use case interacts withactors and what objects are exchanged; thebasic flow and alternative flows of thebehavior.

Ramakant Soni @ BKBIET Pilani

Page 5: Lecture 2   use case diagram-part1

An actor represents a set of roles that usersof use case play when interacting withthese use cases.

Actors can be human or automated

name

5

Actors can be human or automatedsystems.

Actors are entities which require help fromthe system to perform their task or areneeded to execute the system’s functions.

Actors are not part of the system.

Ramakant Soni @ BKBIET Pilani

Page 6: Lecture 2   use case diagram-part1

From the perspective of a given actor, a use case does something that is of value to the actor, such as calculate a result or change the state of an object.

6

change the state of an object.

The Actors define the environments in which the system lives

Ramakant Soni @ BKBIET Pilani

Page 7: Lecture 2   use case diagram-part1

registration

7

student

updatinggrades

outputgenerating

faculty

Ramakant Soni @ BKBIET Pilani

Page 8: Lecture 2   use case diagram-part1

1. Generalization - use cases that arespecialized versions of other use cases.

2. Include - use cases that are included as

8

2. Include - use cases that are included asparts of other use cases. Enable to factorcommon behavior.

3. Extend - use cases that extend thebehavior of other core use cases. Enableto factor variants.

Ramakant Soni @ BKBIET Pilani

Page 9: Lecture 2   use case diagram-part1

The child use case inherits the

behavior and meaning of the

parent use case.

parent

9

parent use case.

The child may add to or

override the behavior of its parent.

child

Ramakant Soni @ BKBIET Pilani

Page 10: Lecture 2   use case diagram-part1

registration

10

graduateregistration

non-graduateregistration

Ramakant Soni @ BKBIET Pilani

Page 11: Lecture 2   use case diagram-part1

The base use case explicitly incorporatesthe behavior of another use case at alocation specified in the base.

base included<<include>>

11

location specified in the base.

The included use case never standsalone. It only occurs as a part of somelarger base that includes it.

Ramakant Soni @ BKBIET Pilani

Page 12: Lecture 2   use case diagram-part1

Enables to avoid describing the same flow of events several times by putting the common behavior in a use case of its own.

12

its own.updatinggrades

outputgenerating

verifyingstudent id

<<include>>

<<include>>

Ramakant Soni @ BKBIET Pilani

Page 13: Lecture 2   use case diagram-part1

Ramakant Soni @ BKBIET Pilani 13

Page 14: Lecture 2   use case diagram-part1

The base use case implicitly incorporatesthe behavior of another use case atcertain points called extension points.

base extending<<extend>>

14

certain points called extension points.

The base use case may stand alone, butunder certain conditions its behaviormay be extended by the behavior ofanother use case.

Ramakant Soni @ BKBIET Pilani

Page 15: Lecture 2   use case diagram-part1

Enables to model optional behavior or branching under conditions.

15

Exam copy request

Exam-grade appeal

<<extend>>

Ramakant Soni @ BKBIET Pilani

Page 16: Lecture 2   use case diagram-part1

Ramakant Soni @ BKBIET Pilani 16

Page 17: Lecture 2   use case diagram-part1

Generalization.

student

17

student

non-graduatestudent

graduatestudent

Ramakant Soni @ BKBIET Pilani

Page 18: Lecture 2   use case diagram-part1

Actors may be connected to use casesby associations, indicating that the actorand the use case communicate withone another using messages.

18

one another using messages.

updatinggrades

faculty

Ramakant Soni @ BKBIET Pilani

Page 19: Lecture 2   use case diagram-part1

placephone call

cellular

placeconference

call

<<extend>>

19

cellularnetwork

user

receivephone call

receiveadditional

call

usescheduler

<<extend>>

Cellular Telephone

Ramakant Soni @ BKBIET Pilani

Page 20: Lecture 2   use case diagram-part1

20Ramakant Soni @ BKBIET Pilani

Page 21: Lecture 2   use case diagram-part1

Each use case may include all or part of the following:

Title or Reference Name - meaningful name of the UC

Author/Date - the author and creation date

Modification/Date - last modification and its date

Purpose - specifies the goal to be achieved

Overview - short description of the processes

21

Overview - short description of the processes

Cross References - requirements references

Actors - agents participating

Pre Conditions - must be true to allow execution

Post Conditions - will be set when completes normally

Normal flow of events - regular flow of activities

Alternative flow of events - other flow of activities

Exceptional flow of events - unusual situations

Implementation issues - foreseen implementation problems

Page 22: Lecture 2   use case diagram-part1

Use Case: Withdraw Money

Author: RS

Date: 19-Nov-2014

Purpose: To withdraw some cash from user’s bank account

Overview: The use case starts when the customer inserts his

22

Overview: The use case starts when the customer inserts hiscredit card into the system. The system requests the user PIN. Thesystem validates the PIN. If the validation succeeded, thecustomer can choose the withdraw operation else alternative 1– validation failure is executed. The customer enters the amountof cash to withdraw. The system checks the amount of cash inthe user account, its credit limit. If the withdraw amount in therange between the current amount + credit limit the systemdispense the cash and prints a withdraw receipt, else alternative2 – amount exceeded is executed.

Cross References: R1.1, R1.2, R7

Ramakant Soni @ BKBIET Pilani

Page 23: Lecture 2   use case diagram-part1

Actors: Customer

Pre Condition:› The ATM must be in a state ready to accept transactions

› The ATM must have at least some cash on hand that it can dispense

› The ATM must have enough paper to print a receipt for at

23

› The ATM must have enough paper to print a receipt for at least one transaction

Post Condition:› The current amount of cash in the user account is the

amount before the withdraw minus the withdraw amount

› A receipt was printed on the withdraw amount

› The withdraw transaction was audit in the System log file

Ramakant Soni @ BKBIET Pilani

Page 24: Lecture 2   use case diagram-part1

Typical Course of events:

Actor Actions System Actions

1. Begins when a Customer arrives at ATM

2. Customer inserts a Credit card into ATM 3. System verifies the customer ID and status

5. Customer chooses “Withdraw” operation 4. System asks for an operation type

24

5. Customer chooses “Withdraw” operation 4. System asks for an operation type

7. Customer enters the cash amount 6. System asks for the withdraw amount

8. System checks if withdraw amount is legal

9. System dispenses the cash

10. System deduces the withdraw amount from account

11. System prints a receipt

13. Customer takes the cash and the receipt 12. System ejects the cash card

Ramakant Soni @ BKBIET Pilani

Page 25: Lecture 2   use case diagram-part1

Alternative flow of events:› Step 3: Customer authorization failed. Display an

error message, cancel the transaction and eject the card.

› Step 8: Customer has insufficient funds in its account.

25

› Step 8: Customer has insufficient funds in its account. Display an error message, and go to step 6.

› Step 8: Customer exceeds its legal amount. Display an error message, and go to step 6.

Exceptional flow of events:› Power failure in the process of the transaction before

step 9, cancel the transaction and eject the card

Ramakant Soni @ BKBIET Pilani

Page 26: Lecture 2   use case diagram-part1

One method to identify use cases is actor-based:- Identify the actors related to a system or organization.- For each actor, identify the processes they initiate or participate in.

A second method to identify use cases is event-based:- Identify the external events that a system must respond to.

- Relate the events to actors and use cases.

The following questions may be used to help identify the use

26

The following questions may be used to help identify the use cases for a system:- What are tasks of each actor ?- Will any actor create, store, change, remove, or read information in the

system ?- What use cases will create, store, change, remove, or read this

information ?- Will any actor need to inform the system about sudden, external changes

? - Does any actor need to be informed about certain occurrences in the

system ?- Can all functional requirements be performed by the use cases ?

Ramakant Soni @ BKBIET Pilani

Page 27: Lecture 2   use case diagram-part1

The “things” that “live” inside the systemare responsible for carrying out thebehavior the actors on the outsideexpect the system to provide.

27

expect the system to provide.

To implement a use case, we create asociety of classes that work together tocarry out the behavior of the use case.

Ramakant Soni @ BKBIET Pilani

Page 28: Lecture 2   use case diagram-part1

Ramakant Soni @ BKBIET Pilani 28

Page 29: Lecture 2   use case diagram-part1

Controller

Water Pump

Hot Water

Water Valve

Home

Temp Sensor

*

29

Fuel Valve90

80

70

60

50

On

Off

Burner

Fuel

Temp Sensor

Control Panel

Ramakant Soni @ BKBIET Pilani

Page 30: Lecture 2   use case diagram-part1

Power Up

Home Heating

Home Owner

MH

Power Down

Change Temp.

30Ramakant Soni @ BKBIET Pilani

Page 31: Lecture 2   use case diagram-part1

Use case : Power UpActors : Home Owner (initiator)Type: Primary and essentialDescription: The Home Owner turns the power on. Each room is temperature

checked. If a room is below the the desired temperature the valve for the room is opened, the water pump started. If the water temp falls the room is opened, the water pump started. If the water temp falls below threshold, the fuel valve is opened, and the burner ignited. If the temperature in all rooms is above the desired temperature, no actions are taken.

Cross Ref.: Requirements XX, YY, and ZZUse-Cases: None

31Ramakant Soni @ BKBIET Pilani

Page 32: Lecture 2   use case diagram-part1

Power Up

Power Down

Home Heating

Adjust Temp

Temp. High

«includes»

«includes»

Home Owner

MH

Change Temp.

Adjust Temp

Temp. Low

«includes»

«includes»

32Ramakant Soni @ BKBIET Pilani

Page 33: Lecture 2   use case diagram-part1

Use case : Power UpActors : Home Owner (initiator)Type : Primary and essentialDescription : The Home Owner turns the power on.

Perform Adjust Temp. If the temperature in all rooms is above the desired temperature, no actions are taken.

*

above the desired temperature, no actions are taken. Cross Ref : Requirements XX, YY, and ZZUse-Cases : Perform Adjust Temp

33Ramakant Soni @ BKBIET Pilani

Page 34: Lecture 2   use case diagram-part1

Ramakant Soni @ BKBIET Pilani 34

Credits : Scott W. Amber

Page 35: Lecture 2   use case diagram-part1

Ramakant Soni @ BKBIET Pilani 35

Credits : Scott W. Amber

Page 36: Lecture 2   use case diagram-part1

Example: Online shopping.

Ramakant Soni @ BKBIET Pilani 36

1.Place Your Primary Actor(S) In The Top-Left Corner Of The Diagram2.Draw Actors To The Outside Of A Use Case Diagram3.Name Actors With Singular, Business-Relevant Nouns4.Associate Each Actor With One Or More Use Cases5.Actors Model Roles, Not Positions6.Use <<system>> to Indicate System Actors7.Actors Don’t Interact With One Another8.Introduce an Actor Called "Time" to Initiate Scheduled Events

Page 37: Lecture 2   use case diagram-part1

Relationships

There are several types of relationships that may appear on a use case diagram:

•An association between an actor and a use case•An association between two use cases•A generalization between two actors•A generalization between two use cases

Ramakant Soni @ BKBIET Pilani 37

Enrolling students in a university

Page 38: Lecture 2   use case diagram-part1

A library lends books to borrowers, who are registered in amembership file. A borrower can reserve a book that is notcurrently available in the library. In a file of books the loaningor reservation of a book will be kept up to date. The librarianis an employee of the library who interacts with thecustomers (borrowers).

Ramakant Soni @ BKBIET Pilani 38

o Design a simple library system for borrowing and returningbooks. The file of books and the membership file may beconsidered as actors.

o Describe one use case by means of a use case text.

Page 39: Lecture 2   use case diagram-part1

Propose a use case diagram for anATM machine for withdrawing cash.Make the use case simple yetinformative; only include the majorfeatures.

Ramakant Soni @ BKBIET Pilani 39

features.

Page 40: Lecture 2   use case diagram-part1

Ramakant Soni @ BKBIET Pilani 40

Page 41: Lecture 2   use case diagram-part1

Propose a use case diagram for avending machine that sells beveragesand snacks. Make use of inclusion andextension associations, markmultiplicities and remember that a

Ramakant Soni @ BKBIET Pilani 41

multiplicities and remember that avending machine may need technicalassistance from time to time.

Page 42: Lecture 2   use case diagram-part1

Ramakant Soni @ BKBIET Pilani 42

Page 43: Lecture 2   use case diagram-part1

References:

[1] http://www.uml-diagrams.org/

[2] http://www.wikipedia.com/UML%diagrams

Ramakant Soni @ BKBIET Pilani 4343


Recommended