Question

I have the following Sequence Diagram consists of two lifelines and synchronous message

enter image description here

I read it as the following :

The "lifeline1" represents an object execute during a period of time.

During lifelin1 execution and exactly at The red circle "lifeline1" needs something from "lifeline2" to be able to complete its execution

So,

1)the "lifeline1" pause its execution and then

2) call synchronous message .(please clarify it a bit in your answer)

The pink line represent the duration of time that the "lifeline1" needs to reach the "lifeline2" to execute

3)The blue rectangle represent the duration of message execution

4)And the dotted line represents the duration of time that the "lifeline2" needs to reach the "lifeline2" to resume its execution.

5)the black rectangle represent the period when a lifeline1 was idle

Does I read properly?

Does I miss any step?

Was it helpful?

Solution

The "lifeline1" represents an object execute during a period of time.

The dotted vertical line represents the object's life time. An 'execution specification' box is drawn on the line when the object is active / executing / has control.

During lifelin1 execution and exactly at The red circle "lifeline1" needs something from "lifeline2" to be able to complete its execution

If it needed something to begin execution, it would not be shown with an execution specification to start with and would instead be shown as becoming active after it received a message.

Instead, the block shows lifeline1 is shown as active, and sending a synchronous message.

1)the "lifeline1" pause its execution and then

No pause (or other timing) is implied by this sequence diagram.

2) call synchronous message .(please clarify it a bit in your answer)

It is similar to calling a method on an object - the flow of control in a synchronous message passes immediately from the sender to receiver, and on receipt of a synchronous message the receiver is shown as the active object.

The pink line represent the duration of time that the "lifeline1" needs to reach the "lifeline2" to execute

No timing is implied by this sequence diagram - it shows the sequence of operations only. Duration timings are shown using the Duration Constraint and Duration Observation notation shown in table 14.1 of the OMG† UML2 Superstructure.

3)The blue rectangle represent the duration of message execution

At the stage in the process represented by the blue rectangle, the 'lifeline2' object is executing in response to the message. Saying 'message execution' is a bit vague - the object is executing, not the message.

4)And the dotted line represents the duration of time that the "lifeline2" needs to reach the "lifeline2" to resume its execution.

The dotted line is a return message. Because the message sent from "lifeline1" is synchronous, it does not continue execution until the return message is received.

5)the black rectangle represent the period when a lifeline1 was idle

Execution specification blocks on UML sequence diagrams represent when the object is actively executing. A object which is idle waiting for a synchronous message to return should be represented without the execution specification block on its lifeline. (the colours have no significance in UML - they are there in this diagram to let you talk about a particular block, they do not to show whether the object is active or not)

I would take a slightly more formal approach and say that the execution should not be shown where it is, but should start after the return message is received to represent that lifeline1 continues - just like the a method which calls a method in another object does not receive flow of control back until the call returns.

However, it very common to show an object which is waiting for a return message with an execution specification as it is sort of still controlling the sequence of operations.

(Unfortunately the UML is so big and fluffy, almost any example anyone comes up with can be read in a different manner. As I have used UML to generate executable models for checking processes for deadlocks using pi-calculus, I tend to have a more rigid interpretation than someone who is, say, writing one on a white board to explain something to a co-developer)

† the Object Management Group who maintain the UML standards, not as in 'OMG it's huge', though that also applies.

OTHER TIPS

Quick Suggestion

Read Sequence Diagrams as a two-dimensional flow chart diagram (activity diagram), like a chessboard.

Long Boring Extended Answer

Imagine a chessboard, where eack square or cell it a place you are moving a figure. The same goes with Sequence Diagrams.

In a sequence diagrams there are columns, where there is an instance of a class (actor, table, boundary, any object), and there rows, where operations are performed.

Imagine that you have a figure that its doing an operation, at time, like the flowcharts, each time an operation or "message" its performed, the figure moves to the next square or cell or block.

Some "cells", of the board, are in the same column (object lifeline).

Sometimes, I draw Sequence Diagrams with linelifes with partitions to help me remember that each partition is a cell or a place where an operation it been performed.

.......................................................
.........+--------------+............+--------------+..
.........| * : FooClass |............| * : BarClass |..
.........+------+-------+............+------+-------+..
................|...........................|..........
................|...........................|..........
............+---+---+...................+---+---+......
.....start..|   |   |......enter()......|   |   |......
..(*)======>|   |   |==================>|   |   |---+..
............|   |   |...................|   |   |...|..
............+---+---+...................+---+---+...|..
............|   |   |.......return......|   |   |...|..
........+---|   |   |<------------------|   |   |<--+..
........|...|   |   |...................|   |   |......
........|...+---+---+...................+---+---+......
........|...|   |   |....PlayChess()....|   |   |......
........+-->|   |   |==================>|   |   |---+..
............|   |   |...................|   |   |...|..
............+---+---+...................+---+---+...|..
............|   |   |.......return......|   |   |...|..
........+---|   |   |<------------------|   |   |<--+..
........|...|   |   |...................|   |   |......
........|...+---+---+...................+---+---+......
........|...|   |   |..HaveRootBeer()...|   |   |......
........+-->|   |   |==================>|   |   |---+..
............|   |   |...................|   |   |...|..
............+---+---+...................+---+---+...|..
............|   |   |......return.......|   |   |...|..
........+---|   |   |<------------------|   |   |<--+..
........|...|   |   |...................|   |   |......
........|...+---+---+...................+---+---+......
........|...|   |   |...GetSandwich()...|   |   |......
........+-->|   |   |==================>|   |   |---+..
............|   |   |...................|   |   |...|..
............#"""+"""#...................+---+---+...|..
............!   |   !...GetFriesAlso()..|   |   |...|..
............!   |   !...............+---|   |   |<--+..
............!   |   !...............|...|   |   |......
............#"""+"""#...............|...+---+---+......
............!   |   !...............|...|   |   |......
............!   |   !...............+-->|   |   |---+..
............!   |   !...................|   |   |...|..
............#"""+"""#...................+---+---+...|..
....finish..|   |   |...................|   |   |...|..
...(O)<-----|   |   |<------------------|   |   |<--+..
............|   |   |...................|   |   |......
............+---+---+...................+---+---+......
................|...........................|..........
................|...........................|..........
................|...........................X..........
.......................................................

The lifelines, indicates that an operation or "message" is performed by an specific object, note, in the example, that some part of lifelines have different characters ("colors") to indicate when an object its idle or busy.

Cheers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top