0

In the below Sequence diagram, when the user have entered the Username and Password, I have to do the authentication. Now you can see two details valid details and invalid detail in the diagram , which i will return when the user password match and miss-match respectively.

Now My big question is which one i have to draw first, either valid details or invalid detail, how I know which one will come first.

Ant's
  • 732
  • 6
  • 17

2 Answers2

2

IMHO it is similar to which order you handle this in code in an if/else branch. In general I prefer handling the common case first (i.e. the valid details in this case), as this makes the code more readable.

But overall on a sequence diagram it doesn't make much difference - do it the way it feels more natural to you (IMHO drawing branches, loops etc. on a sequence diagram is unnatural and ugly enough any way :-).

Péter Török
  • 46,427
  • 16
  • 160
  • 185
2

Neither. I would likely put them on different diagrams. The sequence diagram is supposed to represent a single flow of execution through your design, and these are two different flows.

If you are worried now that you have to duplicate the diagram, and it would be more efficient to represent both you would be right - but remember that your UML will not be compiled - it does not need to represent everything your program does.

Ask yourself why you are drawing this. It is a tool to help describe ( or explore ) your design - you only need to diagram the things that you need to explore, and in many cases it is just the complex flows.

Stephen Bailey
  • 2,236
  • 14
  • 14
  • Ya your correct! I thought of adding it as an separate diagram. but now will do that – Ant's Apr 07 '11 at 15:21
  • I disagree with your single flow of execution statement. IMO a sequence diagram is used to communicate the flow of an operation in your system. There is a reason why Sequence Diagrams have Combined Fragments, which is to show the alternative paths. Why would you want that flow spread out across a bunch of separate diagrams when they can be shown in a single diagram? – Dunk Apr 07 '11 at 17:03
  • I am no UML expert, and don't doubt that there is notation for it, but in practical terms what value you will get out of it. For simple flows like the one above I can understand the notation - but then again for simple flows like that I would never draw a diagram, it feels like over documentation. For more complex flow, the split would create too many lines and remove the value of the diagram to explain a concept. Even in the simple basic guide http://www.ibm.com/developerworks/rational/library/3101.html it looks more complex that I would like. But perhaps it is just the way I would use it? – Stephen Bailey Apr 07 '11 at 18:54