Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I represent a loop in an activity diagram?

Tags:

uml

I'd like to represent a loop in a UML activity diagram. Here's my situation:

  • For each folder, I check each document within that folder
  • For each document I check its content:
    • If it's invalid (based on keyword searching), do action X and pass to next document.
  • When all document are verified, continue to the next folder.

Can anyone show me what this should look like?

like image 767
hereForLearing Avatar asked Jun 08 '16 18:06

hereForLearing


People also ask

How do you represent a loop in an activity diagram?

The loop symbol has an appropriate representation in a construction consisting of four UML activity symbols - TASK, DECISION and two edges, where one edge leads from the TASK to DECISION and the other one leads backwards. The TASK represents the action and the decision node is used to resolve the loop condition.

How do I show a loop in UML?

To show a loop, you use the loop operand with a single fragment and put the basis of the iteration in the guard. For conditional logic, you can use an alt operator and put a condition on each fragment. Only the fragment whose guard is true will execute. If you have only one region, there is an opt operator.

What are the symbols used in activity diagram?

Activity Diagram Tutorial The starting point is usually marked with a dark, filled-in circle with an arrow pointing to the next state usually a rectangle with rounded corners. All action flows are represented with arrows indicating the transitions from state to state.


1 Answers

There are 3 different notations that you can use.

As your loop is based on some elements (folders, documents) the most convenient way is to use Expansion Region (of iterative type). Expansion Region example

Second option, that is a preferred choice when you have some guard based loop is a Loop Node. Loop Node example

The last possibility is to simply build correctly structured decision/merge structure. Decision/Merge example

The benefits of the first two are that they are compact and clear. It is also easy to have nested loops. Neither of this is true with the last option. Yet if you present your diagram to someone who is not familiar with UML (especially if you have no chance to explain a meaning of particular structure), the last approach usually is most widely recognized and understood.

like image 114
Ister Avatar answered Oct 14 '22 12:10

Ister