How to represent an if statement on a sequence diagram in DIA?
Asked Answered
G

1

7

Does anyone know how to represent an if statement on a sequence diagram in DIA?

Guggenheim answered 15/6, 2012 at 14:43 Comment(4)
Take a look at this question...Lido
i don't think it's appropriate for a sequence diagram. the sequence diagram should describe a sequence (as the name hints). in my opinion it should be a sequence from a use case. if the use case has extensions (these represent control flow), then make one sequence diagram for each extension. let the programmer combine this with state diagrams, and then decide if an if-statement is the correct way to control flow. perhaps a state pattern or similar is better suited. that decision should not be made in a sequence diagram :)Boneyard
Also take a look at #6000768.Knuckleduster
@EitanT Check this: ibm.com/developerworks/rational/library/3101.html They represent the 'if'. Thanks for the answers.Guggenheim
W
17

Based on the "alt" box depicted in the IBM link given by @luistm, I was able to replicate something similar in Dia:

UML Sequence Diagram with "alternative combination fragment"

The "alt" box was drawn with the UML Large Package object. (The Small Package doesn't allow you to resize it.)

The condition labels are just Text objects (found on the upper [static] pane in the left toolbar, marked with the T).

The dotted line is just a Line object (from that same static toolbar pane), with the arrowhead set to a plain line, and with the body set to dotted (done at the bottom of the left tool pane, with those 3 arrow segments).

I had to play with the Objects menu items Send to Back, Bring to Front, Send Backwards and Bring Forwards, to get it all to look right without things obstructing one another. Also I had to frequently use the View menu's Refresh command to check myself; often the drawing would mess up the stacking order and overlapping, but the Refresh would put things right again.

It doesn't look exactly like the diagrams at the IBM link (label outside main box instead of inside, box border obstructed by lifeline, etc?), but I think this is the best we can do with Dia's stock UML objects.

Wraf answered 8/8, 2012 at 16:47 Comment(3)
That was my solution to. Thanks for answering.Guggenheim
Is there some special trick to resize the activation box? Dragging the small orange squares (which seems the intuitive thing to do) doesn't work for me.Elroyels
@teo: Yes, resizing the activation box is a little counter-intuitive. What you have to do is right click the activation box and select either "Add connection points" or "Increase connection points distance".Wraf

© 2022 - 2024 — McMap. All rights reserved.