Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Representing loops in a UML activity diagram

Tags:

I am trying to design an activity diagram (UML) for a networked tic tac toe game that I developed, with sockets. I am using activity partitions (swimlanes). So, there is three partitions: Client1, Server, and Client2.

The diagram is looking good, except I do not know how to represent loop structures.

If you look at this link: activity diagram, and look at the last diagram on the page (Partition), that is the type of activity diagram that I am working with.

Does anyone know how I can represent loops? Thanks!

like image 742
littleK Avatar asked Oct 07 '09 17:10

littleK


People also ask

Can an activity diagram represent a loop?

Two possible representation of the loop in the UML activity diagram - a) shows loop where the condition is checked before the action is taken and b) shows the loop where the loop condition is checked after taking action.

How do you 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.

Can activity diagrams have multiple ends?

Yes, there may be cases where multiple endpoints are acceptable. It is possible for an activity diagram to show multiple final states.


2 Answers

Look further down the page you link to for Expansion Region. Use one with the iterative keyword.

An expansion region is a structured activity region that executes multiple times. Input and output expansion nodes are drawn as a group of three boxes representing a multiple selection of items. The keyword "iterative", "parallel" or "stream" is shown in the top left corner of the region.

like image 113
Eric J. Avatar answered Sep 28 '22 04:09

Eric J.


Maybe I'm missing something but why not just using the exit flow of the last activity in the loop as input flow for the first activity in the loop (with a guard condition to finish the loop when appropriate)

like image 26
Jordi Cabot Avatar answered Sep 28 '22 04:09

Jordi Cabot