usecase diagram

24
עעעעע עעעעעע עעעע1 Using Use Case Using Use Case Diagrams Diagrams Use case diagrams are used to Use case diagrams are used to visualize, specify, construct, and visualize, specify, construct, and document the (intended) behavior of document the (intended) behavior of the system, during requirements the system, during requirements capture and analysis. capture and analysis. Provide a way for developers, domain Provide a way for developers, domain experts and end-users to Communicate. experts and end-users to Communicate. Serve as basis for testing. Serve as basis for testing. Use case diagrams contain use cases, Use case diagrams contain use cases, actors, and their relationships. actors, and their relationships.

Upload: robert-john-france-buena

Post on 01-Dec-2014

61 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

1

Using Use Case DiagramsUsing Use Case Diagrams

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

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

Serve as basis for testing.Serve as basis for testing. Use case diagrams contain use cases, actors, and Use case diagrams contain use cases, actors, and

their relationships.their relationships.

Page 2: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

2

Use CaseUse Case

Use cases specify desired behavior. Use cases specify desired behavior. A use case is a description of a set of A use case is a description of a set of

sequences of actions, including variants, a sequences of actions, including variants, a system performs to yield an observable system performs to yield an observable result of value to an actor.result of value to an actor.

Each sequence represent an interaction of Each sequence represent an interaction of actors with the system.actors with the system.

name

Page 3: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

3

Specifying the Behavior of a Use CaseSpecifying the Behavior of a Use Case

Describing the flow of events within the use case.Describing the flow of events within the use case. Can be done in natural language, formal language Can be done in natural language, formal language

or pseudo-code.or pseudo-code. Includes: how and when the use case starts and Includes: how and when the use case starts and

ends; when the use case interacts with actors and ends; when the use case interacts with actors and what objects are exchanged; the basic flow and what objects are exchanged; the basic flow and alternative flows of the behavior.alternative flows of the behavior.

Page 4: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

4

ActorsActors

An actor represents a set of roles that users An actor represents a set of roles that users of use case play when interacting with these of use case play when interacting with these use cases.use cases.

Actors can be human or automated systems.Actors can be human or automated systems. Actors are entities which require help from Actors are entities which require help from

the system to perform their task or are the system to perform their task or are needed to execute the system’s functions.needed to execute the system’s functions.

Actors are not part of the system.Actors are not part of the system.

name

Page 5: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

5

Use Cases and ActorsUse Cases and Actors

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

The Actors define the environments in The Actors define the environments in which the system liveswhich the system lives

Page 6: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

6

Example of Use Case DiagramExample of Use Case Diagram

student

registration

updatinggrades

outputgenerating

faculty

Page 7: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

7

Relationships between Use CasesRelationships between Use Cases

1. Generalization - use cases that are 1. Generalization - use cases that are specialized versions of other use cases.specialized versions of other use cases.

2. Include - use cases that are included as 2. Include - use cases that are included as parts of other use cases. Enable to factor parts of other use cases. Enable to factor common behavior.common behavior.

3. Extend - use cases that extend the behavior 3. Extend - use cases that extend the behavior of other core use cases. Enable to factor of other core use cases. Enable to factor variants.variants.

Page 8: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

8

1. Generalization1. Generalization

The child use case inherits the The child use case inherits the

behavior and meaning of thebehavior and meaning of the

parent use case.parent use case. The child may add to or The child may add to or

override the behavior of its parent.override the behavior of its parent.

parent

child

Page 9: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

9

registration

graduateregistration

non-graduateregistration

More about GeneralizationMore about Generalization

Page 10: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

10

2. Include2. Include

The base use case explicitly incorporates The base use case explicitly incorporates the behavior of another use case at a the behavior of another use case at a location specified in the base.location specified in the base.

The included use case never stands alone. It The included use case never stands alone. It only occurs as a part of some larger base only occurs as a part of some larger base that includes it.that includes it.

base included<<include>>

Page 11: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

11

More about IncludeMore about Include

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

updatinggrades

outputgenerating

verifyingstudent id

<<include>>

<<include>>

Page 12: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

12

3. Extend3. Extend

The base use case implicitly incorporates The base use case implicitly incorporates the behavior of another use case at certain the behavior of another use case at certain points called extension points.points called extension points.

The base use case may stand alone, but The base use case may stand alone, but under certain conditions its behavior may under certain conditions its behavior may be extended by the behavior of another use be extended by the behavior of another use case.case.

base extending<<extend>>

Page 13: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

13

More about ExtendMore about Extend

Enables to model optional behavior or Enables to model optional behavior or branching under conditions.branching under conditions.

Exam copy request

Exam-grade appeal

<<extend>>

Page 14: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

14

Relationships between ActorsRelationships between Actors

Generalization.Generalization.

student

non-graduatestudent

graduatestudent

Page 15: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

15

Relationships between Use Cases Relationships between Use Cases and Actorsand Actors

Actors may be connected to use cases by Actors may be connected to use cases by associations, indicating that the actor and associations, indicating that the actor and the use case communicate with one another the use case communicate with one another using messages.using messages.

updatinggrades

faculty

Page 16: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

16

ExampleExample

placephone call

cellularnetwork

user

receivephone call

placeconference

call

receiveadditional

call

usescheduler

<<extend>>

<<extend>>

Cellular Telephone

Page 17: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

17

Update Items

Bookshop Worker

Ship Order

Bookshop Manager

Update Staff Details

Register Details

Customer1

System Login

Update Customer Details

Add Items to ShoppingCart

Handle Order

<<include>>

<<extend>>

<<include>>

Make Order

<<include>>

A More Complicate ExampleA More Complicate Example

Page 18: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

18

Each use case may include all or part of the followingEach use case may include all or part of the following:: Title or Reference NameTitle or Reference Name - meaningful name of the UC- meaningful name of the UC Author/DateAuthor/Date - the author and creation date- the author and creation date Modification/DateModification/Date - last modification and its date- last modification and its date PurposePurpose - specifies the goal to be achieved- specifies the goal to be achieved OverviewOverview - short description of the processes- short description of the processes Cross ReferencesCross References - requirements references- requirements references ActorsActors - agents participating- agents participating Pre ConditionsPre Conditions - must be true to allow execution- must be true to allow execution Post ConditionsPost Conditions - will be set when completes normally- will be set when completes normally Normal flow of eventsNormal flow of events - regular flow of activities- regular flow of activities Alternative flow of events Alternative flow of events - other flow of activities- other flow of activities Exceptional flow of events Exceptional flow of events - unusual situations- unusual situations Implementation issuesImplementation issues - foreseen implementation problems- foreseen implementation problems

Use Case DescriptionUse Case Description

Page 19: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

19

Example- Money WithdrawExample- Money Withdraw

Use Case: Withdraw MoneyUse Case: Withdraw Money Author: ZBAuthor: ZB Date: 1-OCT-2004Date: 1-OCT-2004 Purpose: To withdraw some cash from user’s bank accountPurpose: To withdraw some cash from user’s bank account Overview: The use case starts when the customer inserts his credit Overview: The use case starts when the customer inserts his credit

card into the system. The system requests the user PIN. The system card into the system. The system requests the user PIN. The system validates the PIN. If the validation succeeded, the customer can validates the PIN. If the validation succeeded, the customer can choose the withdraw operation else alternative 1 – validation failure is choose the withdraw operation else alternative 1 – validation failure is executed. The customer enters the amount of cash to withdraw. The executed. The customer enters the amount of cash to withdraw. The system checks the amount of cash in the user account, its credit limit. system checks the amount of cash in the user account, its credit limit. If the withdraw amount in the range between the current amount + If the withdraw amount in the range between the current amount + credit limit the system dispense the cash and prints a withdraw receipt, credit limit the system dispense the cash and prints a withdraw receipt, else alternative 2 – amount exceeded is executed.else alternative 2 – amount exceeded is executed.

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

Page 20: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

20

Example- Money Withdraw (cont.)Example- Money Withdraw (cont.)

Actors: CustomerActors: Customer Pre Condition:Pre Condition:

– The ATM must be in a state ready to accept transactionsThe ATM must be in a state ready to accept transactions– The ATM must have at least some cash on hand that it can The ATM must have at least some cash on hand that it can

dispensedispense– The ATM must have enough paper to print a receipt for at least The ATM must have enough paper to print a receipt for at least

one transactionone transaction Post Condition:Post Condition:

– The current amount of cash in the user account is the amount The current amount of cash in the user account is the amount before the withdraw minus the withdraw amountbefore the withdraw minus the withdraw amount

– A receipt was printed on the withdraw amountA receipt was printed on the withdraw amount– The withdraw transaction was audit in the System log fileThe withdraw transaction was audit in the System log file

Page 21: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

21

Example- Money Withdraw (cont.)Example- Money Withdraw (cont.)

Typical Course of events:

Actor ActionsActor ActionsSystem ActionsSystem Actions

1. Begins when a Customer arrives at ATM1. Begins when a Customer arrives at ATM

2. Customer inserts a Credit card into ATM2. Customer inserts a Credit card into ATM3. System verifies the customer ID and status3. System verifies the customer ID and status

5. Customer chooses “Withdraw” operation5. Customer chooses “Withdraw” operation4. System asks for an operation type4. System asks for an operation type

7. Customer enters the cash amount7. Customer enters the cash amount6. System asks for the withdraw amount6. System asks for the withdraw amount

8. System checks if withdraw amount is legal8. System checks if withdraw amount is legal

9. System dispenses the cash9. System dispenses the cash

10. System deduces the withdraw amount from 10. System deduces the withdraw amount from accountaccount

11. System prints a receipt11. System prints a receipt

13. Customer takes the cash and the receipt13. Customer takes the cash and the receipt12. System ejects the cash card12. System ejects the cash card

Page 22: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

22

Example- Money Withdraw (cont.)Example- Money Withdraw (cont.)

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

message, cancel the transaction and eject the card.message, cancel the transaction and eject the card.– Step 8: Customer has insufficient funds in its account. Step 8: Customer has insufficient funds in its account.

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

error message, and go to step 6.error message, and go to step 6. Exceptional flow of events:Exceptional flow of events:

– Power failure in the process of the transaction before Power failure in the process of the transaction before step 9, cancel the transaction and eject the cardstep 9, cancel the transaction and eject the card

Page 23: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

23

Example- Money Withdraw (cont.)Example- Money Withdraw (cont.)

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

A second method to identify use cases is event-based:A second method to identify use cases is event-based: - Identify the external events that a system must respond to.- Identify the external events that a system must respond to. - Relate the events to actors and use cases.- Relate the events to actors and use cases. The following questions may be used to help identify the use cases for The following questions may be used to help identify the use cases for

a system:a system:- What are tasks of each actor ?What are tasks of each actor ?- Will any actor create, store, change, remove, or read information in the system ?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 ?What use cases will create, store, change, remove, or read this information ?- Will any actor need to inform the system about sudden, external changes ? 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 ?Does any actor need to be informed about certain occurrences in the system ?- Can all functional requirements be performed by the use cases ?Can all functional requirements be performed by the use cases ?

Page 24: UseCase Diagram

ע

ידמ

ת כו

ערמ

ח תו

ני

24

Moving onMoving on

The “things” that “live” inside the system The “things” that “live” inside the system are responsible for carrying out the are responsible for carrying out the behavior the actors on the outside expect behavior the actors on the outside expect the system to provide.the system to provide.

To implement a use case, we create a To implement a use case, we create a society of classes that work together to society of classes that work together to carry out the behavior of the use case.carry out the behavior of the use case.