CS 2511 Fall 2014
UML Diagram Types 2 Main Types Structure Diagrams ○ Class Diagrams ○ Component Diagrams ○ Object Diagrams Behavior Diagrams ○ Sequence Diagrams ○ Use Case Diagrams
Sequence Diagrams sequence diagram A sequence diagram in Unified Modeling Language (UML) is a kind of interaction diagram that shows how processes operate with one another and in what order. objects In Java most of the interaction between processes is done via objects, and thus a sequence diagram basically shows how objects interact with other objects.
Organization Object Name: Class Name :Class NameObject Name Method Call
Some Important Points Each use case can be depicted as a sequence diagram. An underline with the class name and/or object name usually means that the entity being displayed is an object not a class.
Object Each box represents an Object that is alive (i.e. it’s constructor has been called) at a particular time in the computation. 3 options to represent objects : Object Name: Class Name :Class NameObject Name
LifeLines The time for which an object is “alive” i.e. still in scope (which means has not been garbage collected yet) is represented by a life line. smallCircle :Circle
Activation Bars Activation bars are used to represent the time when an object is calling a method. The activation bars ends when the method that was called returns. smallCircle :Circle myMonitor: Display methodCall( ) Returned from method
Call Arrows and Method Names A call is represented by an arrow going from one object to another. Method Names are represented on the call arrow. :BridgeProblem currentState :BridgeState >
Examples Code : public static void main(String[] args) { BridgeState initialState = new BridgeState("west", "west", "west", "west", "west", 0); BridgeState finalState = new BridgeState("east", "east", "east", "east", "east", 17); initialState.display(); finalState.display(); }
Sequence Diagram initialState: BridgeState > finalState: BridgeState > display() BridgeTest1. main