Search code examples
umlactivity-diagram

Activity diagram optional flows (OR logic)


This question can be a basic one. But I could not find an answer by googling or searching in the SO.

I have a user who can perform three actions.

  • View dashboard
  • View reports
  • Create users

When the user logs in to the system he can do one or more tasks from the above list in any order before he logs out.

Some examples:

  1. View dashboard -> View reports -> View dashboard -> Logout

  2. View dashboard -> View reports -> Create user -> View report -> Create user -> View dashboard -> Logout

Can I cover all the possible combinations simply by adding a fork and a join as below? Or what is the general practice to sketch this kind of situation. Thank you.

enter image description here


Solution

  • No, that's not correct. The fork/join create a parallel flow. That means all three actions must be taken and finished until the Logout can take place.

    It's a bit tricky to draw these conditions:

    enter image description here

    The A/B/C possible guards let you choose once any action. I abbreviated that in the drawing but you can simply add a note to the diagram explaining that. Or if you dare you can write some OCL. Same for the Logout which can only be taken one of the other actions have run once. There's a simple loop so you can select each action one after the other.