1

This question is a follow-up to Representing multiple actions for sequence of objects on activity diagram, but isn't strictly related. The question boils down to:

How to present in UML patterns that behave differently depending on how network of handlers is configured.

In simplest case I have the following:

<cfg>
    <handler id="1" />
    <handler id="2" />
</cfg>

This means that during execution data will be passed first to handler-1 and then to handler-2. But configuration can be changed so that flow is handler-2 and then handler-1, or even handler-2, handler-1, handler-1, handler-2.

And what if handlers can be composed/combined? I can easily create class diagrams for such shenanigans, but activity or sequence diagrams are completely beyond me.

  • I'm afraid there's no general pattern that can be applied always. Can you lost specific situations so that through examples you might grasp a better understanding? – Ister Mar 16 '18 at 7:01
1

I don't think there's a general answer to your question. You have to take the cases one-by-one, since the devil is in the details.

This means that during execution data will be passed first to handler-1 and then to handler-2.

It's not 100% clear what you mean, but I'll show you two ways to show this in UML with a sequence diagram:

UML Sequence diagram showing data passed to handlers

But configuration can be changed so that flow is handler-2 and then handler-1, or even handler-2, handler-1, handler-1, handler-2.

You can use the same notation as above to show each case.

And what if handlers can be composed/combined?

Again, sequence diagrams are pretty explicit, so you have to be precise. One way you can show general calling of a method inside a list of elements is as follows:

UML Sequence diagram showing data passed to an aggregate of handlers

As you mentioned, in UML you could (should) complement this with the static structure of the aggregate (composition) of handlers with a class diagram.

If the traversal of the composite structure is complex (i.e., not just a straightforward list or tree iteration), you could diagram it with an activity diagram.

You could check out the UML diagrams for the Chain of Responsibility pattern, too, since this is related to your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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