SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized...
-
Upload
desiree-tall -
Category
Documents
-
view
230 -
download
0
Transcript of SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized...
![Page 1: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/1.jpg)
SEQUENCE DIAGRAM
![Page 2: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/2.jpg)
UML diagrams
There are many ways of organizing the UML diagrams. Can be organized as the fallowing:
1. Structural diagrams: to show the building blocks of your system—features that don’t
change with time. Ex: Class diagram
2. Behavioral diagrams: to show how your system responds to requests or otherwise
evolves over time. Ex: Use case diagram
3. Interaction diagrams: Is a type of behavioral diagram. to depict the exchange of messages within a collaboration (a
group of cooperating objects). Ex: Sequence diagram & Collaboration diagram
![Page 3: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/3.jpg)
Interaction Diagrams A series of diagrams describing the dynamic
behavior of an object-oriented system. A set of messages exchanged among a set of
objects within a context to accomplish a purpose.
Often used to model the way a use case is realized through a sequence of messages between objects.
The purpose of Interaction diagrams is to:– Model interactions between objects– Assist in understanding how a system (a use case) actually works– Verify that a use case description can be supported by the existing classes– Identify responsibilities/operations and assign them to classes
![Page 4: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/4.jpg)
Interaction Diagrams
UML Collaboration Diagrams
Emphasizes structural relations between objects
Sequence Diagram The subject of this lecture
![Page 5: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/5.jpg)
Sequence Diagrams
Illustrates how objects interacts with each other.
Emphasizes time ordering of messages. Can model simple sequential flow,
branching, iteration, recursion and concurrency.
![Page 6: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/6.jpg)
UML sequence diagrams
Used during requirements analysis To refine use case
descriptions to find additional
objects (“participating objects”)
Used during system design to refine subsystem
interfaces Classes are represented by
columns Messages are represented
by arrows Activations are
represented by narrow rectangles
Lifelines are represented by dashed lines
selectZone()
pickupChange()
pickUpTicket()
insertCoins()
PassengerTicketMachine
![Page 7: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/7.jpg)
Nested messages
The source of an arrow indicates the activation which sent the message
An activation is as long as all nested activations
Horizontal dashed arrows indicate data flow
Vertical dashed lines indicate lifelines
selectZone()
PassengerZone Selection F. TarifSchedule Display
lookupPrice(selection)
displayPrice(price)price
Dataflow
…to be continued...
![Page 8: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/8.jpg)
Iteration & condition
Iteration is denoted by a * preceding the message name Condition is denoted by boolean expression in [ ] before the message
name
PassengerChangeProcessor
insertChange(coin)
CoinIdentifier Display CoinDrop
displayPrice ( billed Amount)
lookupCoin(coin)
price
[billed Amount<0] returnChange(-billedAmount)
Iteration
Condition…to be continued...
…continued from previous slide...
*
![Page 9: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/9.jpg)
Creation and destruction
Creation is denoted by a message arrow pointing to the object.
Destruction is denoted by an X mark at the end of the destruction activation.
In garbage collection environments, destruction can be used to denote the end of the useful life of an object.
PassengerChangeProcessor
…continued from previous slide...
Ticket
createTicket(selection)
free()
Creation
Destruction
print()
![Page 10: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/10.jpg)
Software Design (UML)
Sequence Diagram
An object in a sequence diagram is rendered
as a box with a dashed line descending from it.
The line is called the object lifeline, and it
represents the existence of an object over a
period of time.
an Order Line
![Page 11: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/11.jpg)
Software Design (UML)
Sequence Diagraman Order Line a Stock Item
[check = “true”] remove()
check()
Messages are rendered as horizontal
arrows being passed from object to
object as time advances down the
object lifelines. Conditions ( such as
[check = “true”] ) indicate when a
message gets passed.
![Page 12: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/12.jpg)
Software Design (UML)
Sequence Diagraman Order Line a Stock Item
[check = “true”] remove()
check() Notice that the bottom arrow is different. The arrow head is not solid, and there is no accompanying message.
This arrow indicates a return from a previous message, not a new message.
![Page 13: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/13.jpg)
Software Design (UML)
Sequence Diagraman Order a Order Line
* prepare() An iteration marker, such as * (as shown), or *[i = 1..n] , indicates that a message will be repeated as indicated.
Iterationmarker
![Page 14: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/14.jpg)
Software Design (UML)
an Order Entrywindow
an Order an Order Line a Stock Item
A ReorderItem
A DeliveryItem
new
[check = “true”] new
[needsToReorder = “true”]
needsToReorder()
[check = “true”] remove()
check()
* prepare()
prepare()
Object
Message
Iteration
Return
Creation
Condition
Self-Delegation
[Fowler,97]
![Page 15: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/15.jpg)
Basic Elements of a Sequence Diagram
Active Objects Actors or Objects Notated using the UML notation for class
instances “Life line” appears below active objects to
indicate their lifespan Messages
Arrowed lines that indicated communication between objects
![Page 16: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/16.jpg)
Three Active Objects with Two Messages
Chessboard Database
Chess Player
make move
record move
critique
![Page 17: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/17.jpg)
Message Types
Synchronous message (wait for return)
Return messages (response to previous message)
Asynchronous messages (no wait)
Flat (unspecified synchronization)
Note closed arrowhead
![Page 18: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/18.jpg)
Creating/Deleting Objects
Send messages <<create>> and <<destroys>>
Chessboard
Database<<create>>
critique<<destroys>>
![Page 19: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/19.jpg)
Conditional Messages
Chessboard
Database<<create>>
critique
[unfavorable critique] <<destroys>>
![Page 20: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/20.jpg)
Branching
Chessboard Database
Chess Player
[make move]
critique
[resign]
![Page 21: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/21.jpg)
Alternative Flow
Chessboard Database
Chess Player
[make move]
[game over]
![Page 22: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/22.jpg)
Control Rectangles
Show when an object is involved in a sequence of messages
Chessboard ChessEngine
Request Position
Request Evaluation
Database
Record Data
![Page 23: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/23.jpg)
Modeling Time
Chess Client Chess Server
Send Player’s Move
Send Opponent’s Move
Diagonal message lines indicate that the messages take time to transmit
![Page 24: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/24.jpg)
Specifying a Time Constraint on a message
Chess Client Chess Server
Send Player’s Move
Send Opponent’s Move
{sendTime for player’s move<2 seconds}
![Page 25: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/25.jpg)
Modeling Loops
Chess Client Chess Server
Send Player’s Move
Send Opponent’s Move
*[while !gameOver]
![Page 26: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/26.jpg)
Modeling Recursion
Application Sorter
Sort List
Sort List
![Page 27: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/27.jpg)
Arguments and Return Values
Web Interface
Database
GPA = RequestGPA(studentName)
![Page 28: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/28.jpg)
Adding Notes to Diagrams
Chess Client Chess Server
Send Player’s Move
Send Opponent’s Move
Send a move and get a move. If connection is lost, an automatic reconnect is attempted.
![Page 29: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/29.jpg)
System Diagram notation
class instance named instance
:Sale s1:SaleSale
Which would you expect to find most often in a sequence diagrams?
![Page 30: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/30.jpg)
Sequence Diagram Notation
: Register : Sale
doA
doB
doX
doC
doD
typical sychronous message shown with a filled-arrow line
a found message whose sender will not be specified
execution specification bar indicates focus of control
Figure 15.7
![Page 31: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/31.jpg)
What does vertical placement communicate?
: Register : Sale
makePayment(cashTendered)
: Paymentcreate(cashTendered)
authorize
note that newly created objects are placed at their creation "height"
Figure 15.10
![Page 32: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/32.jpg)
Examples
![Page 33: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/33.jpg)
Example 1: Part of a Vending Machine
![Page 34: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/34.jpg)
Example 2: ATM
![Page 35: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/35.jpg)
Example 2: ATM in Detail
![Page 36: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/36.jpg)
Example 3: Shopping Cart
![Page 37: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/37.jpg)
Example 4: Video Rental
![Page 38: SEQUENCE DIAGRAM. UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show.](https://reader036.fdocuments.net/reader036/viewer/2022062303/551a1cad550346a4248b4e2d/html5/thumbnails/38.jpg)
Sequence Diagram Summary UML sequence diagram represent
behavior in terms of interactions. Useful to find missing objects. Time consuming to build but worth the
investment. Complement the class diagrams (which
represent structure).