System Sequence Diagrams Recap When to create SSD

  • Slides: 22
Download presentation
System Sequence Diagrams

System Sequence Diagrams

Recap • • When to create SSD? How to identify classes/instances? Use case descriptions

Recap • • When to create SSD? How to identify classes/instances? Use case descriptions UML notations for SSD

Contents • Interaction diagrams • UML notation • Examples

Contents • Interaction diagrams • UML notation • Examples

Interaction Diagrams • Show objects interact with one another • UML supports two types

Interaction Diagrams • Show objects interact with one another • UML supports two types of interaction diagrams Ø Sequence diagrams Ø Collaboration diagrams

Sequence Diagrams • AKA Interaction Diagrams – Semantically equivalent to Collaboration Diagrams • Dynamic

Sequence Diagrams • AKA Interaction Diagrams – Semantically equivalent to Collaboration Diagrams • Dynamic Model relating use cases and class diagrams • Illustrates how objects interacts with each other • Shows time ordering of interactions • Generally a set of messages between collaborating objects • Ordering of objects not significant

Sequence Diagrams • Show only one flow of control • Can model simple sequential

Sequence Diagrams • Show only one flow of control • Can model simple sequential flow, branching, iteration, recursion and concurrency • May need multiple diagrams – Primary – Variant – Exceptions

UML sequence diagrams • sequence diagram: an "interaction diagram" that models a single scenario

UML sequence diagrams • sequence diagram: an "interaction diagram" that models a single scenario executing in the system – perhaps 2 nd most used UML diagram (behind class diagram) • relation of UML diagrams to other exercises: – CRC cards -> class diagram – use cases -> sequence diagrams 7

Key parts of a sequence diag. • participant: an object or entity that acts

Key parts of a sequence diag. • participant: an object or entity that acts in the sequence diagram – sequence diagram starts with an unattached "found message" arrow • message: communication between participant objects • the axes in a sequence diagram: – horizontal: which object/participant is acting – vertical: time (down -> forward in time) 8

Sequence Diagram (Basic) Object : Class or Actor Lifeline Focus of Control/ Activation X

Sequence Diagram (Basic) Object : Class or Actor Lifeline Focus of Control/ Activation X Object Destruction/ Termination name message <<create>> <<destroy>>

Sequence Diagram (Basic) Student a. Class: Class Register : Scheduler adjust. Room check. Rooms

Sequence Diagram (Basic) Student a. Class: Class Register : Scheduler adjust. Room check. Rooms

Sequence Diagrams (Advanced) Seq# [Guard] *[Iteration] Return-List : = Operation-Name (Argument-List) *[Iteration Condition] recursion

Sequence Diagrams (Advanced) Seq# [Guard] *[Iteration] Return-List : = Operation-Name (Argument-List) *[Iteration Condition] recursion Conditional Lifeline {transient}

Sequence Diagram(make a phone call) Caller Phone Recipient Picks up Dial tone Dial Ring

Sequence Diagram(make a phone call) Caller Phone Recipient Picks up Dial tone Dial Ring notification Ring Picks up Hello

Sequence Diagrams – Object Life Spans • Creation A Ø Create message Ø Object

Sequence Diagrams – Object Life Spans • Creation A Ø Create message Ø Object life starts at that point • Activation Ø Symbolized by rectangular stripes Ø Place on the lifeline where object is activated. Ø Rectangle also denotes when object is deactivated. Activation bar • Deletion Ø Placing an ‘X’ on lifeline Ø Object’s life ends at that point Lifeline Create Return B X Deletion

Sequence diag. from use case 14

Sequence diag. from use case 14

Lifetime of objects • creation: arrow with 'new' written above it – notice that

Lifetime of objects • creation: arrow with 'new' written above it – notice that an object created after the start of the scenario appears lower than the others • deletion: an X at bottom of object's lifeline – Java doesn't explicitly delete objects; they fall out of scope and are garbage-collected 15

Representing objects • squares with object type, optionally preceded by object name and colon

Representing objects • squares with object type, optionally preceded by object name and colon – write object's name if it clarifies the diagram – object's "life line" represented by dashed vert. line 16

Messages between objects • message (method call) indicated by horizontal arrow to other object

Messages between objects • message (method call) indicated by horizontal arrow to other object – write message name and arguments above arrow 17

Messages between objects – dashed arrow back indicates return – different arrowheads for normal

Messages between objects – dashed arrow back indicates return – different arrowheads for normal / concurrent (asynchronous) methods

Example

Example

Example

Example

Example

Example

Summary • SSD revision • Loops • Conditions in SSD

Summary • SSD revision • Loops • Conditions in SSD