Presentation is loading. Please wait.

Presentation is loading. Please wait.

SEQUENCE DIAGRAM Prepared by: T. Fatimah Alageel.

Similar presentations


Presentation on theme: "SEQUENCE DIAGRAM Prepared by: T. Fatimah Alageel."— Presentation transcript:

1 SEQUENCE DIAGRAM Prepared by: T. Fatimah Alageel

2 UML diagrams There are many ways of organizing the UML diagrams. Can be organized as the fallowing: 1. Structural diagrams: to show the building blocks of your system—features that don’t change with time. Ex: Class diagram 2. Behavioral diagrams: to show how your system responds to requests or otherwise evolves over time. Ex: Use case diagram 3. Interaction diagrams: Is a type of behavioral diagram. to depict the exchange of messages within a collaboration (a group of cooperating objects). Ex: Sequence diagram & Collaboration diagram

3 Interaction Diagrams  A series of diagrams describing the dynamic behavior of an object-oriented system.  A set of messages exchanged among a set of objects within a context to accomplish a purpose.  Often used to model the way a use case is realized through a sequence of messages between objects.  The purpose of Interaction diagrams is to: –Model interactions between objects –Assist in understanding how a system (a use case) actually works –Verify that a use case description can be supported by the existing classes –Identify responsibilities/operations and assign them to classes

4 Interaction Diagrams  UML  Collaboration Diagrams Emphasizes structural relations between objects  Sequence Diagram The subject of this lecture

5 Sequence Diagrams  Illustrates how objects interacts with each other.  Emphasizes time ordering of messages.  Can model simple sequential flow, branching, iteration, recursion and concurrency.

6 UML sequence diagrams  Used during requirements analysis  To refine use case descriptions  to find additional objects (“participating objects”)  Used during system design  to refine subsystem interfaces  Classes are represented by columns  Messages are represented by arrows  Activations are represented by narrow rectangles  Lifelines are represented by dashed lines selectZone() pickupChange() pickUpTicket() insertCoins() Passenger TicketMachine

7 Nested messages  The source of an arrow indicates the activation which sent the message  An activation is as long as all nested activations  Horizontal dashed arrows indicate data flow  Vertical dashed lines indicate lifelines selectZone() Passenger Zone Selection F. TarifScheduleDisplay lookupPrice(selection) displayPrice(price) price Dataflow …to be continued...

8 Iteration & condition  Iteration is denoted by a * preceding the message name  Condition is denoted by boolean expression in [ ] before the message name Passenger ChangeProcessor insertChange(coin) CoinIdentifierDisplayCoinDrop displayPrice ( billed Amount) lookupCoin(coin) price [billed Amount<0] returnChange(-billedAmount) Iteration Condition …to be continued... …continued from previous slide... *

9 Creation and destruction  Creation is denoted by a message arrow pointing to the object.  Destruction is denoted by an X mark at the end of the destruction activation.  In garbage collection environments, destruction can be used to denote the end of the useful life of an object. Passenger ChangeProcessor …continued from previous slide... Ticket createTicket(selection) free() Creation Destruction print()

10 Software Design (UML) Sequence Diagram An object in a sequence diagram is rendered as a box with a dashed line descending from it. The line is called the object lifeline, and it represents the existence of an object over a period of time. an Order Line

11 Software Design (UML) Sequence Diagram an Order Linea Stock Item [check = “true”] remove() check() Messages are rendered as horizontal arrows being passed from object to object as time advances down the object lifelines. Conditions ( such as [check = “true”] ) indicate when a message gets passed.

12 Software Design (UML) Sequence Diagram an Order Linea Stock Item [check = “true”] remove() check() Notice that the bottom arrow is different. The arrow head is not solid, and there is no accompanying message. This arrow indicates a return from a previous message, not a new message.

13 Software Design (UML) Sequence Diagram an Ordera Order Line * prepare() An iteration marker, such as * (as shown), or *[i = 1..n], indicates that a message will be repeated as indicated. Iteration marker

14 Software Design (UML) an Order Entry window an Orderan Order Linea Stock Item A Reorder Item A Delivery Item new [check = “true”] new [needsToReorder = “true”] needsToReorder() [check = “true”] remove() check() * prepare() prepare() Object Message Iteration Return Creation Condition Self-Delegation [Fowler,97]

15 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

16

17 Three Active Objects with Two Messages ChessboardDatabase Chess Player make move record move critique

18 Message Types  Synchronous message (wait for return)  Return messages ( response to previous message)  Asynchronous messages (no wait)  Flat (unspecified synchronization) Note closed arrowhead

19 Creating/Deleting Objects  Send messages > and > Chessboard Database > critique >

20 Conditional Messages Chessboard Database > critique [unfavorable critique] >

21 Branching ChessboardDatabase Chess Player [make move] critique [resign]

22 Alternative Flow ChessboardDatabase Chess Player [make move] [game over]

23 Control Rectangles  Show when an object is involved in a sequence of messages ChessboardChessEngine Request Position Request Evaluation Database Record Data

24 Modeling Time Chess ClientChess Server Send Player’s Move Send Opponent’s Move Diagonal message lines indicate that the messages take time to transmit

25 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}

26 Modeling Loops Chess ClientChess Server Send Player’s Move Send Opponent’s Move *[while !gameOver]

27 Modeling Recursion ApplicationSorter Sort List

28 Arguments and Return Values Web InterfaceDatabase GPA = RequestGPA(studentName)

29 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.

30 System Diagram notation Which would you expect to find most often in a sequence diagrams?

31 Sequence Diagram Notation Figure 15.7

32 What does vertical placement communicate? Figure 15.10


Download ppt "SEQUENCE DIAGRAM Prepared by: T. Fatimah Alageel."

Similar presentations


Ads by Google