1

EDIT: This question led to another, namely Representing handlers on UML diagram.

I'm trying to create an Activity Diagram that shows that a collection of objects is handled by a collection of handlers. Something along the lines:

Objects objs = { ... };
Handlers handlers = { ... };

for (o in objs) {
    for (h in handlers) {
        h.handle(o);
    }
}

It is a real world problem, we have a list of dates and we want to call an unknown number of processes, in order, sequentially, and pass this date to each one. Is it something that can be easily shown on activity diagram?

When it comes to drawing I'm basically stuck in initial node, so there's not much to show in response to "show us what you have already".

Update:

After reading yesterday about expansion regions and objects and few other things, I came up with the following:

Active objects - proposition

2 Answers 2

2

While your question is a very specific one it actually winds down to a question how to represent a loop using an activity diagram. I strongly recommend checking this answer. In your case I guess the first approach from the answer is the most suitable.

4
  • Thank you for the link. I tried to do something with expansion regions, but I guess my main problem is not "how to represent looping" but rather "how to show on an activity diagram than action (so rectangle with rounder corner) represent operation provided by object that comes in from what is basically a different activity. I start to wonder whether it is something that should be shown on activity diagram. Mar 13, 2018 at 8:15
  • Oh well, it's a bit different question. Dig more into object nodes, pins and parameters of activity.
    – Ister
    Mar 13, 2018 at 8:29
  • Thanks again for an answer. I added proposition of solution - I read about things you said yesterday and came up with it. Am I in any way on a right track or is it as far from UML as possible? Of course I could settle for this as UML is "just a notation", but it is always better to do things in more standard way... Mar 13, 2018 at 8:46
  • Yes, you're going in the right direction now, however adding the girl makes it a bit unclear to me. How many handlers are selected for a specific data? Is it preselected in a way independent to the data that'll be handled? If it should be independent, place both outside of the extension region and use two entry parameter sets, one for data collection and one for handler collection.
    – Ister
    Mar 16, 2018 at 6:45
2

I haven't seen anyone use an activity diagram (aka flow chart) for source code, professionally, for decades but if someone is insisting, it would look something like this:

enter image description here

10
  • You're not using an UML notation, just a good old-school block diagram notation.
    – Ister
    Mar 12, 2018 at 17:57
  • @Ister better now? Mar 12, 2018 at 18:15
  • Close, but Handle is also an action so should have rounded corners. A simple rectangle represent an object which is not the case you want to show here. Also the flow has to end in a node, in your case it should go back to the decision node (diamond) that already exists (a single diamond can be simultaneously a decision and a merge node) or you can add additional one. In general consecutive diamonds are considered a poor modelling and should be avoided, replaced with a good conditions on outgoing flows (check the answer I've provided to see how to achieve that for nested loops as asked by OP).
    – Ister
    Mar 12, 2018 at 18:45
  • @Ister and now? Mar 12, 2018 at 19:11
  • 1
    @Ister before I change it again ask yourself if the lack of arrowheads on every node is really hurting readability. I'm trying to keep it from feeling cluttered. Mar 12, 2018 at 21:26

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.