6

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

Jax Teller
  • 163
  • 2
  • 18
  • 2
    Could it be that "But I don't necessarily have an output collection." actually means you have an _empty collection_? – qwerty_so Apr 04 '19 at 09:14
  • @ThomasKilian I have an input collection that I iterate over. Based upon actions taken I would do something to another collection that is not part of the loop itself. – Jax Teller Apr 04 '19 at 10:02

2 Answers2

4

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.

Axel Scheithauer
  • 2,758
  • 5
  • 13
  • Thanks for the explanation. The outgoing control flow from an expansion region is in my EA not possible, I only get the dependency option. Unless I add the ControlFlow to something else and then shift it over tot he expansion region manually. The point with the activity nodes I now understand. – Jax Teller Apr 11 '19 at 10:21
  • EA just tries to guess, what relationships make sense in a certain situation and offers those in the quick link menu. UML contains a lot of relationships, so that EA cannot always guess what you need. However, you can always look up the relationship in the toolbox and create it from there. – Axel Scheithauer Apr 12 '19 at 15:40
  • I just skimme the specs and did not find any use of the arrows in the parameters. That's more SysML-like. What's your tool of choice? It isn't EA sinsce tha's still using 3 parted boxes while ste standard (and your tool) shows 4. – qwerty_so Apr 14 '19 at 05:45
  • @ThomasKilian: Are you referring to the Expansion Nodes? There is no example in the specification, however, the notation with small arrows is mentioned in section 16.12.4. The tool I used in this diagram is Magic Draw. – Axel Scheithauer Apr 15 '19 at 17:43
  • No dice. I'm looking into formal/2015-03-01 – qwerty_so Apr 15 '19 at 21:10
  • In this Document it says: „a small arrow can be used [for ExpansionNodes] as with Pins“. Technically it is not mentioned that multiple arrows can be shown. However, I would consider this to be covered by the artistic freedom of the tool vendor. – Axel Scheithauer Apr 17 '19 at 10:35
1

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).

qwerty_so
  • 35,448
  • 8
  • 62
  • 86
  • And do you know, if for example I have no output collection (empty collection), how do I signal a flow from one loop to another? For instance, in the first loop I want to loop over a collection, then in a nested loop, loop over another collection, some actions/activities are done, a separate collection (global as you have mentioned) is filled/changed. How would you jump to the next item in an iteration if for example the current item doesn't fit the criteria, activity final? But activity final would indicate the end of an activity, which would also mean end of the entire loop? – Jax Teller Apr 05 '19 at 05:25
  • 1
    You should no try to "program graphically". Leave that to the coder. Your AD shall give an **overview** not a a detailed coding instruction. You could use Structured Activities (2nd in the context menu of EA) for these details. But: don't overdo it. – qwerty_so Apr 05 '19 at 08:30
  • Yes, I think that's one of the main issues for people new to UML. Thanks. – Jax Teller Apr 05 '19 at 09:03