240 likes | 399 Views
Sequence Diagrams. Show Sequence of Interactions Between Objects. Sequence Diagrams Realize use-cases Show interaction between system objects Collaboration Diagrams are an alternative method also used in UML. Why use sequence diagrams?. Active Objects Actors or Objects
E N D
Sequence Diagrams Show Sequence of Interactions Between Objects
Sequence Diagrams • Realize use-cases • Show interaction between system objects • Collaboration Diagrams are an alternative method also used in UML Why use sequence diagrams?
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 Basic Elements of a Sequence Diagram
Chessboard Database Chess Player make move record move critique Three Active Objects with Two Messages
Synchronous message (wait for return) • Return messages (response to previous message) • Asynchronous messages (no wait) • Flat (unspecified synchronization) Note closed arrowhead Message Types
Send messages <<create>> and <<destroys>> Chessboard Database <<create>> critique <<destroys>> Creating/Deleting Objects
Chessboard Database <<create>> critique [unfavorable critique] <<destroys>> Conditional Messages
Rectangle with rounded corners Chessboard W White to move White’s move W Black to move Object State
Chessboard Database Chess Player [resign] [make move] critique Branching
Chessboard Database Chess Player [game over] [make move] Alternative Flow
Show when an object is involved in a sequence of messages Chessboard ChessEngine Database Request Position Request Evaluation Record Data Control Rectangles
Chess Client Chess Server Diagonal message lines indicate that the messages take time to transmit Send Player’s Move Send Opponent’s Move Modeling Time
Chess Client Chess Server {sendTime for player’s move<2 seconds} Send Player’s Move Send Opponent’s Move Specifying a Time Constraint on a message
Chess Client Chess Server Send Player’s Move {Roundtrip time < 1 second} Send Opponent’s Move Specifying a time constraint on a section
Chess Client Chess Server Send Player’s Move Send Opponent’s Move Modeling Loops *[while !gameOver]
Application Sorter Sort List Sort List Modeling Recursion
Web Interface Database GPA = RequestGPA(studentName) Arguments and Return Values
Chess Client Chess Server Send Player’s Move Send a move and get a move. If connection is lost, an automatic reconnect is attempted. Send Opponent’s Move Adding Notes to Diagrams
They look like activity diagrams, but they are showing state transitions. Statechart Diagrams
Start Symbol End Symbol State Symbol (contains state name) Decision Points Symbols
Events are indicated by adding labels to the edges between states Events
Actions show the behavior associated with an action • Actions are: • Entry – what happens on entry • Exit – what happens on exit • Do – what happens while in the state • Include – an additional statechart diagram • Event – how to respond to an event Actions
For non-events • Action-label/action for non-events • For events • Event-name(parameters) [guard] /action • Examples: • Entry/numberOfStudents=0 • RestUsers(users) [Users->forAll(Open = False)] / users->empty Action Notation
Data State Deleted Exit/ Reset Cancel/ EmptyData() Data Entered / RecoredData() Clean Dirty Continue/ SaveData() Exit/ Reset() Saved Example (from Roff)