Sequence Diagrams Show Sequence of Interactions Between Objects
Why use sequence diagrams? Sequence Diagrams ◦Realize use-cases ◦Show interaction between system objects Collaboration Diagrams are an alternative method also used in UML
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
Three Active Objects with Two Messages ChessboardDatabase Chess Player make move record move critique
Message Types Synchronous message (wait for return) Return messages ( response to previous message) Asynchronous messages (no wait) Flat (unspecified synchronization) Note closed arrowhead
Creating/Deleting Objects Send messages > and > Chessboard Database > critique >
Conditional Messages Chessboard Database > critique [unfavorable critique] >
Object State Rectangle with rounded corners W White to move Chessboard W Black to move White’s move
Branching ChessboardDatabase Chess Player [make move] critique [resign]
Alternative Flow ChessboardDatabase Chess Player [make move] [game over]
Control Rectangles Show when an object is involved in a sequence of messages ChessboardChessEngine Request Position Request Evaluation Database Record Data
Modeling Time Chess ClientChess Server Send Player’s Move Send Opponent’s Move Diagonal message lines indicate that the messages take time to transmit
Specifying a Time Constraint on a message Chess ClientChess Server Send Player’s Move Send Opponent’s Move {sendTime for player’s move<2 seconds}
Specifying a time constraint on a section Chess ClientChess Server Send Player’s Move Send Opponent’s Move {Roundtrip time < 1 second}
Modeling Loops Chess ClientChess Server Send Player’s Move Send Opponent’s Move *[while !gameOver]
Modeling Recursion ApplicationSorter Sort List
Arguments and Return Values Web Interface Database GPA = RequestGPA(studentName)
Adding Notes to Diagrams Chess ClientChess 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.
Statechart Diagrams They look like activity diagrams, but they are showing state transitions.
Symbols Start Symbol End Symbol State Symbol (contains state name) Decision Points
Events Events are indicated by adding labels to the edges between states
Actions 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
Action Notation 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
Example (from Roff) CleanDirty Saved Data Entered / RecoredData() Deleted Data State Exit/ Reset Cancel/ EmptyData() Continue/ SaveData() Exit/ Reset()