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

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 :-).

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.