Sequence Diagrams Show Sequence of Interactions Between Objects
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) Note closed arrowhead � Return messages (response to previous message) � Asynchronous � Flat messages (no wait) (unspecified synchronization) Message Types
� Send messages <<create>> and <<destroys>> Chessboard <<create>> Database critique <<destroys>> Creating/Deleting Objects
Chessboard <<create>> Database critique [unfavorable critique] <<destroys>> Conditional Messages
�Rectangle with rounded corners Chessboard White to W move White’s move Black to W move Object State
Chessboard Chess Player [resign] [make move] critique Branching Database
Chessboard Database Chess Player [game over] [make move] Alternative Flow
� Show when an object is involved in a sequence of messages Chessboard Chess. Engine Request Position Request Evaluation Record Data Control Rectangles Database
Chess Client Chess Server Send Player’s Move Send Opponent’s Move Modeling Time Diagonal message lines indicate that the messages take time to transmit
Chess Client {send. Time for player’s move<2 seconds} Chess Server 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 *[while !game. Over] Modeling Loops
Application Sorter Sort List Modeling Recursion
Web Interface Database GPA = Request. GPA(student. Name) Arguments and Return Values
Chess Client Send a move and get a move. If connection is lost, an automatic reconnect is attempted. Chess Server Send Player’s Move 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/number. Of. Students=0 ◦ Rest. Users(users) [Users->for. All(Open = False)] / users->empty Action Notation
Data State Deleted Exit/ Reset Cancel/ Empty. Data() Clean Data Entered / Recored. Data() Dirty Continue/ Save. Data() Exit/ Reset() Saved Example (from Roff)
- Slides: 24