Professional Documents
Culture Documents
INTRODUCTION
TO
SOFTWARE ENGINEERING
1
Source: Pressman – IS501 course notes
REMEMBER LAST LESSON
• Nonfunctional requirements
• Portability
• Reliability
• Efficiency
• Usability
• Maintability
• Characteristics of good SRS
• Class Diagram
• State Machine Diagram
2
The way
things
“happen”
The way
things “are”
3
SEQUENCE DIAGRAMS
A sequence diagram shows
• a particular sequence of messages exchanged between
a number of participants and
• the behavior by showing the sequence of messages among
them
• one particular communication sequence in one run of the
system
• it is not characterizing all possible runs
A sequence diagram can be used for
• showing the system’s behavior that corresponds to a use-
case
• generating test cases for the software product
SEQUENCE DIAGRAMS
Show conditional behavior on separate diagrams to keep them
understandable
• for example for a use case you can give the basic path as
one sequence diagram and have separate sequence
diagrams for alternative paths or exceptions
Use sequence diagrams to show the behavior of several
objects within a use case
6
SEQUENCE
DIAGRAM
NOTATION
focus of control
or activation
7
GUIDELINES FOR SEQUENCE DIAGRAMS
8
EXAMPLE: SEQUENCE DIAGRAM
SESSION WITH AN ONLINE STOCKBROKER
9
EXAMPLE: SEQUENCE
DIAGRAM STOCK PURCHASE
10
EXAMPLE: SEQUENCE
DIAGRAM STOCK QUOTE
11
EXAMPLE: SEQUENCE
DIAGRAM STOCK PURCHASE
THAT FAILS
12
EXAMPLE:
ATM
13
QUESTION 1
Draw a sequence diagram for the following
Purchase items scenario:
• Customer brings items to the counter.
• Cashier scans each customer item.
• Cashier totals order, including tax.
• Cashier requests form of payment.
• Customer gives a credit card.
• Cashier scans card.
• Checkout system communicates scan data to verifier.
• Verifier reports that credit card payment is acceptable.
• Customer signs credit card slip.
14
ANSWER 1
15
QUESTION 2
Draw a sequence diagram for the get email scenario
below:
• User logs in to email system.
• System displays the mail in the Inbox folder.
• User requests that system get new email.
• System requests new email from server.
• Server returns new email to system.
• System displays the mail in the Inbox folder and highlights
unread messages.
16
ANSWER 2
17
ACTIVITY DIAGRAMS
A activity diagram shows a sequence of steps that make
up a complex process such as an algorithm or a
workflow.
• In early versions of UML there was no way of drawing a flowchart.
Notation:
Elongated oval: shows activites
Arrow: shows sequencing
Diamond: shows decision points
Bar: splitting or nesting of concurrent
steps.
18
ACTIVITY DIAGRAM NOTATION
19
EXAMPLE:
ACTIVITY DIAGRAM OF STOCK TRADE PROCESSING
If the order execution fails, then the system sends a failure notice
to the customer and closes the order.
20
EXAMPLE:
ACTIVITY DIAGRAM OF
STOCK TRADE PROCESSING
The online stock broker first verifies the order against the
customer’s account, then executes it with the stock exchange.
If the order executes successfully, the system does tree things
concurrently:
• Mails trade confirmation to the customer
• Updates the online portfolio to reflect the results of the trade
• Settles the trade with the other party by debiting the account
and transferring cash or securities.
When all three concurrent threads have been completed, the
system merges control into a single tread and closes the order.
If the order execution fails, then the system sends a
failure notice to the customer and closes the order.
21
EXAMPLE:
ACTIVITY DIAGRAM OF
STOCK TRADE PROCESSING
22
EXAMPLE:
ACTIVITY DIAGRAM OF STOCK
TRADE PROCESSING
An activity may be decomposed into finer activities
23
EXAMPLE:
CASH WITHDRAWAL FROM ATM
Based on your experience with a bank ATM, draw an activity
diagram that models the data processing involved when a
customer withdraws cash from the machine.
EXAMPLE 4:
ACTIVITY DIAGRAM FOR CASH WITHDRAWAL
EXAMPLE:
ACTIVITY DIAGRAM FOR CARD VERIFICATION
26
GUIDELINES FOR
ACTIVITY DIAGRAMS
Activity diagrams are used to elaborate use cases.
• Do not use activity diagrams for developing software via flowcharts.
Activities on a diagram should have a consistent level of
detail.
If there are conditions, at least one must be satisfied when
an activity completes.
• Consider using an else condition
Concurrency means that activities can complete in any
order and still yield an acceptable result.
• All inputs must first complete before a merge can happen
27
QUESTION 1
Prepare an activity diagram for computing a restaurant bill.
28
ANSWER 1
29
QUESTION 2
Prepare an activity diagram for awarding frequent flyer
credits. A minimum of 750 miles is credit for each flight. Gold
and red card holders receive a minimum of 1000 miles per
flight. Gold card holders receive a 25% bonus for any flight.
Red card holders receive a 50% bonus for any flight.
30
ANSWER 2
31
DIAGRAM EXERCISES
32