How to model optional actions on UML activity diagram

Michael Albers picture Michael Albers · Apr 29, 2015 · Viewed 9.8k times · Source

After searching the net and a couple of old fashioned books I own, I still haven't found my answer to how to model an activity for a specific use case. I am fairly new to UML and thus activity diagrams.

The activity is Add hotel. This is fictional, but the issue is exactly the same as my issue. My contract prevents me from talking about the real deal to third parties.

In this activity the user provides necessary details and has two optional actions that he can choose at anytime while in the Add hotel activity:

  1. Add hotel chain
  2. Add loyalty program

As said these are optional and not mandatory. The user is also able to proceed to save the entered data. However, when choosing one of these actions, I imagine another activity diagram should be invoked, named the same as the choice the user made. In this activity all relevant stuff is entered and at the endpoint the user returns to the Add a hotel activity after which the user has the option to choose the optional activities again or proceed to save the provided data.

The only somewhat relevant answer I found was this one

But as I understand it, a fork means all actions after it have to be carried out before the flow will continue after the join. And in case of a decision, only one option can be chosen.

The actions 1 and 2 above, are also available from other locations in the application. I just need to make them available on the Add hotel activity.

So how would I go about modelling optional actions that are available all the time during the flow of an activity? And why should it be done that way (if not obvious after reading) Also, does it matter if these optional actions are Atomic actions or CallBehavior actions?

Like is said, I'm fairly new to UML, so it might well be possible that I interpret some things wrongly.

Answer

qwerty_so picture qwerty_so · Apr 29, 2015

You're correct in the assumption that a fork will continue in all paths. To make an optional process simply use a Decision node (looks like a lozenge). From there you can proceed to your two optional actions or skip. Finally join the path again with the very same lozenge to merge the optional paths.

Basically it might look like this (not taking all the details of your activity into account):

enter image description here Just ignore all those fuzzy details about different actions. Atomic is enough for a start.