Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use expansion regions for loops in an activity diagram?

I am having problems designing a proper UML activity diagram.

I've seen similar questions and possible answers: How to present a loop in activity diagram?

Even with these answers I am having doubts and my own answer doesn't correspond with the UML definitions.

Summarization of the problem: Loop over folders and files in each folder, act upon each folder depending on its name and upon each file depending on its name. The main problem I am having is if I am using the expansion region correctly.

Many sources tell that an expansion region must have an input collection and an output collection. But I don't necessarily have an output collection.

Is it automatically assumed that the Region will iterate over all items until no items are left before it goes into ActivityFinal?

Here is a Enterprise Architect screenshot of what I've done: enter image description here

like image 881
Jax Teller Avatar asked Apr 04 '19 07:04

Jax Teller


2 Answers

First of all, your Expansion Nodes are connected with Control Flows or your Actions are connected with Object Flows, either of which is impossible (too bad, that EA doesn't enforce this rule). That means you need to have an Action after the Initial Node, that provides you with a collection. Also you are using Activities in an Activity-Diagram. Contrary to popular believe (and to EA), this is not allowed. You should use Actions (possibly CallBehaviorActions calling Activities, but that's up to you).

I don't know exactly what you try to model. However here is my suggestion for a valid use of Expansion Regions: enter image description here The first Expansion Node creates an object token for each folder in the directory. The second Expansion Node creates an object token for each file in the folder. If you need to access the folder name, you can simply draw an Object Flow into the Region. This will then provide a separate folder token for each execution of the inner Expansion Region.

It is not necessary to model an output Expansion Node, if you don't need one. Simply end each execution with a Flow Final Node. After the last execution finishes, the Region will produce a token for the outgoing Control Flow.

like image 96
Axel Scheithauer Avatar answered Nov 15 '22 06:11

Axel Scheithauer


Based on your reply it's just an object you are acting on.

enter image description here

You can just put that object in a global context outside of your expansion region. The input-/output-parameters just stay the same. They are the analogon of procedure parameters. In case you fiddle with the external (global) object your return value would be some empty collection (and possibly some information that you dealt with the external object).

like image 32
qwerty_so Avatar answered Nov 15 '22 05:11

qwerty_so