7

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

2
  • 2
    Could it be that "But I don't necessarily have an output collection." actually means you have an empty collection?
    – qwerty_so
    Apr 4, 2019 at 9: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 4, 2019 at 10:02

2 Answers 2

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.

6
  • 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, 2019 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. Apr 12, 2019 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, 2019 at 5: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. Apr 15, 2019 at 17:43
  • No dice. I'm looking into formal/2015-03-01
    – qwerty_so
    Apr 15, 2019 at 21:10
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).

3
  • 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 5, 2019 at 5: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 5, 2019 at 8:30
  • Yes, I think that's one of the main issues for people new to UML. Thanks.
    – Jax Teller
    Apr 5, 2019 at 9:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.