1 / 32

Sequence Diagram

Sequence Diagram. Prepared by: T. Fatimah Alageel. UML diagrams. There are many ways of organizing the UML diagrams. Can be organized as the fallowing: Structural diagrams: to show the building blocks of your system—features that don’t change with time. Ex: Class diagram

adler
Télécharger la présentation

Sequence Diagram

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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: • Structural diagrams: • to show the building blocks of your system—features that don’t change with time. • Ex: Class diagram • Behavioral diagrams: • to show how your system responds to requests or otherwise evolves over time. • Ex: Use case diagram • 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 & Collaborationdiagram

  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. TicketMachine Passenger selectZone() insertCoins() pickupChange() pickUpTicket() 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

  7. TarifSchedule Display Passenger selectZone() lookupPrice(selection) displayPrice(price) price Nested messages Zone Selection F. Dataflow • 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 …to be continued...

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

  9. Passenger createTicket(selection) Ticket print() free() Creation and destruction …continued from previous slide... Creation ChangeProcessor • 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. Destruction

  10. an Order Line 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. Software Design (UML)

  11. Sequence Diagram an Order Line a Stock Item 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. check() [check = “true”] remove() Software Design (UML)

  12. Sequence Diagram an Order Line a Stock Item 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. [check = “true”] remove() Software Design (UML)

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

  14. an Order Entrywindow an Order an Order Line a Stock Item [Fowler,97] prepare() Condition * prepare() Object check() [check = “true”] remove() Message needsToReorder() Iteration Self-Delegation Return [needsToReorder = “true”] new A ReorderItem [check = “true”] new A DeliveryItem Creation Software Design (UML)

  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. Three Active Objects with Two Messages Chessboard Database Chess Player make move record move critique

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

  18. Creating/Deleting Objects • Send messages <<create>> and <<destroys>> Chessboard Database <<create>> critique <<destroys>>

  19. Conditional Messages Chessboard Database <<create>> critique [unfavorable critique] <<destroys>>

  20. Branching Chessboard Database Chess Player [resign] [make move] critique

  21. Alternative Flow Chessboard Database Chess Player [game over] [make move]

  22. Control Rectangles • Show when an object is involved in a sequence of messages Chessboard ChessEngine Database Request Position Request Evaluation Record Data

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

  24. Specifying a Time Constraint on a message Chess Client Chess Server {sendTime for player’s move<2 seconds} Send Player’s Move Send Opponent’s Move

  25. Modeling Loops Chess Client Chess Server Send Player’s Move Send Opponent’s Move *[while !gameOver]

  26. Modeling Recursion Application Sorter Sort List Sort List

  27. Arguments and Return Values Web Interface Database GPA = RequestGPA(studentName)

  28. Adding Notes to Diagrams Chess Client Chess Server Send Player’s Move Send a move and get a move. If connection is lost, an automatic reconnect is attempted. Send Opponent’s Move

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

  30. Sequence Diagram Notation Figure 15.7

  31. What does vertical placement communicate? Figure 15.10

More Related