Interaction Diagrams (S8 CS)

Interaction Diagrams

  • An interaction diagram shows an interaction, consisting of a set of objects and their relationships, including the messages that may be dispatched among them
  • Figure 1 Interaction Diagrams
  • Interaction diagrams commonly contain Objects, Links, Messages
  • interaction diagrams are used to model the dynamic aspects of a system
  • An interaction diagram is basically a projection of the elements found in an interaction.
  • It may contain notes and constraints

    Figure 1: Interaction Diagrams

Sequence Diagrams

  • A sequence diagram is an interaction diagram that emphasizes the time ordering of  messages
  • Graphically it is a table that shows objects arranged along the X axis   and messages ordered in increasing time along the Y axis
  • Figure 2 Sequence Diagram
  • place the objects that participate in the interaction at the top of your diagram, across the X axis, object that initiates the interaction at the left, and increasingly more subordinate objects to the right
  • place the messages that these objects send and receive along the Y axis, in order of   increasing time from top to bottom

    Figure 2: Sequence Diagram

Sequence diagrams have two features that distinguish them from collaboration diagrams

  • First, there is the object lifeline which is a vertical dashed line that represents the existence of an object over a period of time
  • Second, there is the focus of control which is a tall, thin rectangle that shows the period of time during which an object is performing an action, either directly or through a subordinate procedure

Collaboration Diagrams

  • A collaboration diagram is an interaction diagram that emphasizes the structural organization of the objects that send and receive messages
  • Graphically it is a collection of vertices and arcs
  • Figure 3 Collaboration Diagram
  • more-complex flows, involving iterations and branching are modeled as [i := 1n] (or  just ), [x > 0]

    Figure 3: Collaboration Diagram

Collaboration diagrams have two features that distinguish them from sequence diagrams

  • First, there is the path to indicate how one object is linked to another, you can attach a path stereotype to the far end of a link such as local, parameter, global, and self
  • Second, there is the sequence number to indicate the time order of a message denoted by prefixing the message with a number, nesting is indicated by Dewey decimal numbering (eg:- 1 is the   first message; 1.1 is the first message nested in message 1.)

Semantic Equivalence

sequence diagrams and collaboration diagrams are semantically equivalent that means conversion to the other is possible without any loss of information.

Modeling Flows of Control by Time Ordering

To model a flow of control by time ordering,

  • Set the context for the interaction, whether it is a system, subsystem, operation, or class or one scenario of a use case or collaboration
  • Set the stage for the interaction by identifying which objects play a role in the interaction. Lay them out on the sequence diagram from left to right, placing the more important objects to the left and their neighboring objects to the right
  • Set the lifeline for each object. In most cases, objects will persist through the entire interaction. For those objects that are created and destroyed during the interaction, set their lifelines, as appropriate, and explicitly indicate their birth and death with appropriately stereotyped messages
  • Starting with the message that initiates this interaction, lay out each subsequent message from top to bottom between the lifelines, showing each message’s properties (such as its parameters), as necessary to explain the semantics of the interaction
  • If you need to visualize the nesting of messages or the points in time when actual computation is taking place, adorn each object’s lifeline with its focus of control
  • If you need to specify time or space constraints, adorn each message with a timing mark and attach suitable time or space constraints
  • If you need to specify this flow of control more formally, attach pre- conditions and post-conditions to each message

Figure 4 shows a sequence diagram that specifies the flow of control involved in initiating a simple, two-party phone call

Figure 4: Modeling Flows of Control by Time Ordering

Modeling Flows of Control by Organization

To model a flow of control by organization

  • Set the context for the interaction, whether it is a system, subsystem, operation, or class or one scenario of a use case or collaboration
  • Set the stage for the interaction by identifying which objects play a role in the interaction .Lay them out on the collaboration diagram as vertices in a graph, placing the more important objects in the center of the diagram and their neighboring objects to the outside
  • Set the initial properties of each of these objects If the attribute values, tagged values, state or role of any object changes in significant ways over the duration of the interaction, place a duplicate object on the diagram, update it with these new values, and connect them by a message stereotyped as become or copy (with a suitable sequence number)
  • Specify the links among these objects, along which messages may pass
  1. Lay out the association links first; these are the most important ones, because they represent structural connections
  2. Lay out other links next, and adorn them with suitable path stereotypes (such as global and local) to explicitly specify how these objects are related to one another
  • Starting with the message that initiates this interaction, attach each subsequent message to the appropriate link, setting its sequence number, as appropriate Show nesting by using Dewey decimal numbering
  • If you need to specify time or space constraints, adorn each message with a timing mark and attach suitable time or space constraints
  • If you need to specify this flow of control more formally, attach pre- and post-conditions to each message

Figure 5 shows a collaboration diagram that specifies the flow of control involved in registering a new student at a school, with an emphasis on the structural relationships among these objects

Figure 5: Modeling Flows of Control by Organization