You are on page 1of 19

Interaction Diagrams

Sequence Diagrams
Collaboration Diagrams
Sequence Diagrams
•The Sequence Diagram is one of the most interesting and
useful diagrams in the Unified Modeling Language (UML).
•It helps to document and understand the dynamic aspects of
software system—specifically the sequence of messages that
are sent and received between objects.
•Sequence diagrams can help you comprehend and solve
difficult issues in the process-intensive portions of your
applications.

•Sequence diagrams show the time ordering of messages


between objects
Sequence Diagrams
Sequence diagrams help you answer two very important
questions:

1. Which objects should be assigned a particular


responsibility?
2. In what order should messages pass between objects?
Sequence Diagrams

Modeling Use Cases

So, what kinds of things should you document in a sequence


diagram?

Usually, a sequence diagram is used to document the logic


of a use case.
Sequence Diagram
Sequence Diagrams
Sequence Diagram Elements

There are four primary elements of a sequence diagram:

•Objects
•Lifelines
•Messages
•Focus of control
Sequence Diagrams
•It has two dimensions. Vertical represents Time, Horizontal
represents different objects.

•It shows an interaction arranged in time sequence.

•The vertical line is called the object’s Lifeline.

•The lifeline represents the object’s existence during interaction


or lifespan of an object over a period of time.

•Each message is represented by an arrow between the lifelines


of two objects.
Sequence Diagrams
• The order in which these messages occur is shown top to
bottom in the diagram.

•Message indicate when one object calls an operation on


another object (or itself).

•Each message is labeled with a message name.

•The label can also include argument and some control


information and show self delegation.
Sequence Diagrams
•Focus of control (FOC) is used in sequence diagrams to show the
period of time during which an object performs an action.

•FOC is rendered as a thin, rectangular object that sits on top of


object lifelines.

•The top of the FOC rectangle coincides with the receipt of a


message.

•The bottom of the rectangle coincides with the completion of an


action and can be marked with a return message
Sequence Diagrams
Creation and Deletion of Objects

The vertical position of an object in a sequence diagram


indicates when it is instantiated.
If an object is "alive" from the beginning of the entire
sequence, you should place it at the top of the diagram and
its lifelines should extend to the bottom.
If an object is instantiated at a later time, you should move it
down the vertical axis to the place at which it is instantiated.
If an object is destroyed before the end of a sequence, you
can indicate this by placing an "X" at the bottom of the
lifeline at the point where the object is released.
Sequence Diagrams
Two control info:

1. Condition – Indicates when a message is sent.

2. Iteration Marker – A message is sent many times to


multiple receiver objects.

A return from a message is indicated using dashed


arrow.
Concurrent processes and
Activations
• When a transaction is created, it creates a Transaction
Coordinator to coordinate the checking of the Transaction.
• This coordinator creates a number of transaction checker
objects, each of which is responsible for a particular check.
• Each checker is called asynchronously and proceeds in
parallel.
• The half arrowheads indicate an asynchronous message.
It does:
1. Create a new thread, in which case it links to the top of an
activation.
2. Create a new object.
3. Communicate with a thread that is already running.
Sequence Diagram:Check failure
Collaboration Diagram
Collaboration Diagram

•It represents a collaboration, which is a set of objects related


in a particular context, and interaction, which is a set of
messages exchanged among the objects within the
collaboration to achieve a desired outcome.

•The sequence is indicated by numbering the messages.

•It is more compressed.

•This helps to show how the objects are linked together and
the layout can be overlaid with packages.
Collaboration Diagram with decimal numbering
Sequence Diagrams
Note: When you add a message to a sequence diagram,
most modeling tools automatically add a corresponding
operation to the class that receives the message

•It is an alternative way to understand the overall


flow of the control of a program.
•It helps to understand the sequence quickly

You might also like