0

I have created a Sequence Diagram that I wish to convert to a Communication/Collaboration Diagram. I understand the conversion and the numbering process but I am wondering since my Sequence diagram have loops that are under the alt fragment, how is their numbering going to be in Communication Diagram?

Here a sample of my Sequence Diagram that have one of those loops: enter image description here

Edit: What I want to know here is that since the loop is an IF situation, is it still OK to number those sequences? I don't think it would make logic if user's communication is, 1.0 Enter registered Username and Password, 2.0 Re-enter registered Username and Password...2.0 here is the IF loop situation

Christophe
  • 68,716
  • 7
  • 72
  • 138
Dlyne
  • 13
  • 4
  • Possible duplicate of [Representing loops in a UML communication diagram](http://stackoverflow.com/questions/10202095/representing-loops-in-a-uml-communication-diagram) – qwerty_so Jan 22 '17 at 10:32
  • @ThomasKilian the other answer is totally not what I am looking for. I have edited my question to be more specific. Thank you anyways for your reply. – Dlyne Jan 22 '17 at 11:52
  • Well, the answer says that you can't do loops in communication diagrams. And that's basically it. You can add comments to show you intention. But then, why not use a SD?? – qwerty_so Jan 22 '17 at 12:31
  • @ThomasKilian This is actually a part of my project. The requirement needs me to model an SD and CD. I actually saw in other tutorials where the loops are counted as part of the communication. But i felt that it didn't made sense. That's why i wanted to confirm if it is possible. I guess this question have no solid answer then. Maybe then I will specify the IF condition like what you said with adding comments. Thank you very much. – Dlyne Jan 22 '17 at 14:05
  • You "could" number accordingly, but a loop can be performed multiple times (of course). So you would need to use as many numbers as the loop is performed. This will make reading impossible. So simply: in case of loops use a note or better use a SD. – qwerty_so Jan 22 '17 at 14:20
  • @ThomasKilian exactly my point with the loop problem. Ok i'll use a note. Thank you. – Dlyne Jan 22 '17 at 14:30
  • I've corrected the title to refer to the communication diagram. Collaboration diagram is old UML 1. – Christophe Nov 27 '21 at 15:27

1 Answers1

0

Communication diagram and sequence diagram represent the same interactions from a different angle. But the simplified graphical representation of the messages implies restrictions in the communication diagram when it comes to combined fragments.

In the communication diagram you can represent:

  • simple sequence of messages and nested messages, via the chronological numbering, e.g.: 1,2,3 and decimal numbering, e.g. 2.1, 2.2, 2.2.1
  • loops (loop operator in sequence diagram), using a * following the number. More specific looping specifications could follow the start between brackets e.g. *[1..n] or *[element in collection]. Your loop conditions are unspecified in the sequence diagram, so a * would do.
  • simple conditions (opt operator in sequence diagram), using a condition between brackets after the number e.g.[t>10]

In your example, we could therefore imagine: `

1: Enters username and passord
2: Check validity
2.1*: Mismatch of name or password    // return message, not usual     
2.2:  Prompt user to re-enter credentials
2.3:  Re-enter username and password
2.4:  Re-check validity               // missing in the SD in the loop
3: Verify user
4: USer verified
5: Display profile  

Now there are two issues here: first, in your sequence diagram, there is a missing check validity in the loop. Second, I showed for simplicity all the messages, but in a communication diagram you would usually not sho return messages, to keep things simpler. So we'd have a slightly simpler model:

1: Enters username and passord
2: Check validity   //message, return is implicit
3.1*[credentials invalid]: Prompt user to re-enter credentials      
3.2: Re-enter username and password
3.3: Check validity 
4: Read user
5: Display profile  

Advice for the choice between SD and CD:

  • if you have many involved lifelines, either make several smaller SDs or opt for the CD.
  • if you have many message exchanges, especially between the same lifelines, prefer SD, because following the numbers on a CD is exponentially unintuitive with the increase of messages, and long lists of messages above the arrows look ugly.
  • if you have many combined fragments, or if you have more than loops and optionals, stay with SD.
Christophe
  • 68,716
  • 7
  • 72
  • 138