UML example: WD40

In this example, we’ll translate a classical flowchart into a UML activity diagram. First introduce yourself to the diagram and figure out the 4 possible flows in it.

Since the diagram is already describing a flow, the only thing we need to do is convert it to UML using the standardized language elements.

Look at the flowchart and think of the following:

  • Where are decisions being made? They may be presented as questions wit ha Yes or No answers. Use UML decision node.
  • Where are the actions? Use UML action state.
  • Where is the start of the algorithm? Use UML start node.
  • Where is the end? Could there be multiple endings? Use UML end node.
  • Think, can there be some things in the flowchart that are not needed for the UML activity diagram. E.g. if nothing is being done, then doing noting is not an action – it’s the absence of an action.

Recommendation: before going forward, solve the task by creating a UML activity diagram based on the given flowchart and compare your solution. 

NB! There are multiple correct solutions for this conversion. Before showing you the solution, lets go over some mistakes.

Common mistakes

Before looking at the solution, lets make sure that you didn’t do any of the following mistakes.

  • Answers “Yes” and “No” are not actions. They cannot be placed inside action states – only actions where we can do something go there. In this case, they are answers to the question which we based our decision node on.
  • Missing merge node – if multiple flows merge (after being separated by decision nodes), you must use a merge node to join them. In the case of merge node not being available, you can reuse a decision node. Do not use a join node! Join node is only  used for synchronization of parallel flows after a fork node.

Solution

This would be one possible solution for the task.

Variations

As said, this algorithm has multiple correct solutions. Some alterations could be as follows:

  • The algorithm can have 3 different endings – one where nothing is being done, one where WD40 will be applied and one where duct tape will be applied. A merge node must precede the ending where nothing will be done. It’s also important to comment all of the endings differently (e.g. WD40 applied to reduce friction).
  • Questions such as “Does it move” do not need to be written as a note element. Note can be omitted and the answers can directly be written on the control flow arrows. (E.g. for the first decision node, they could it that “The object moves” and “The object does not move”. When writing decision node this way, the question itself will not be present in the design.)
  • The questions themselves can be brought out as action  – e.g. “Ask of the object moves?”. Adding the question as an action state does not affect the decision nodes. You are not allowed to omit anything from the decision by adding the question as an action. Since this can be considered as redundant, it was omitted from the sample solution.