activity diagram - how to show multiple objects passed between two actions? - uml

Background
I have one action (action_a) that calls an operation(operation_x) on another action (action_b).
The parameters to operation_x are as follows:
action_b.operation_x( param_1, param_2 )
I'm trying to work out how to document the parameters being passed in UML activity diagrams.
Option 1
One option may be to use a comment?
Option 2
Another option may be to use activity parameters, but it doesn't seem right to show two flows from action_a for one operation call?
Question
How can I show multiple objects being passed?

Option 2 is close, but the edges coming out of action_a are not right, and I don't think it's legal to show the call and the details on the same diagram. Please see my other answer.

Related

How to connect two activities? [duplicate]

This question already has answers here:
Can't connect activities in activity diagram in EA
(3 answers)
Closed 1 year ago.
I'm looking over internet for the solution but I can't find anything.
I have a big system with multiple interfaces.
In our company we have an uml repository where we have an activity diagrams for all use cases.
And here:
I know that I should use actions on activity diagram and I can't connect two activities by control flow.
But
We want to have also reusable actions/activities for interface methods with diagram for the method body.
Is there any possibility to connect two activities by object flow or control flow?
I can't connect two activities by control flow
Is there any possibility to connect two activities by object flow or control flow?
you want to call an activity from an other, for that just use a call behavior action where the behavior is the called activity.
From ยง16.3.4.1 Call Behavior Action page 454 of formal/2017-12-05 :
The call of an Activity is indicated by placing a rake-style symbol within the Action symbol (see Figure 16.15, left). The
rake resembles a miniature hierarchy, indicating that this invocation starts another Activity that represents a further
decomposition. An alternative notation in the case of an invoked Activity is to show the contents of the invoked Activity
inside a large round-cornered rectangle symbol (see Figure 16.15, right).

Methods in a Sequence Diagram

I am creating this sequence diagram, and wondered exactly what methods to include. I have included all methods in every method, for example, the
handleCustomerAccountAction()
method, got a method from another class called
getListOfCustomers()
Is that right to do, or do you only have to include the method and not all the methods it uses inside it?
Also, is it okay to show the same method multiple times on other methods? For example the method
getListOfCustomers()
is shown three times (the one with a loop around it), but from different methods.
Here is the image of my sequence diagram:
It always depends on what you want to show. A SD shows a certain collaboration you want to explain in detail. A SD should focus on a certain aspect and must not show each and every message (e.g. certain call branches can simply be left out). However, if a method is called twice in a sequence you must show it if it's of importance.

How to depict nested action/activities in a UML Activity Diagram?

I would like to create an activity diagram in which one of the actions is depicted with its sub-actions.
To better clarify I would like to be able to depict something like the following diagram
The problem in my case is that SubActivity1 does not have any input parameter. I just want SubActivity1 to start its execution when OpaqueAction1 is completed.
I know that it is possible to use a CallBehaviorAction to express that an Action will result in the execution of another Activity like in the following diagram
But, in this way I cannot depict the sub-actions in the same activity diagram.
I also thought of using a StructuredActivityNode like in the following diagram
here the problem is that I am not able to show the name of the StructuredActivityNode. I do not know whether this is an issue of the tool that I am using (Papyrus) or it is a general issue.
What you always can do it to use diagram frames and place them inside an activity:
If you need to pass parameters and make use of them inside an activity you can do it this way:
The action pin on Action1 takes the parameter to process it. As you see, you can also place the contents of an Activity manually inside its frame.
An activity is completed when it has reached its last action. More explicitly you should use a flow final to show that. I omitted it in the first example since your examples lacked it. But I usually place it at the end of each (sub-)flow.

Are return arrows allowed in a UML Activity Diagram

I would like to represent the following in a UML Activity Diagram
1) User requests a product list from Application
2) Application requests product list from Database
3) Database returns product list to Application
4) Application displays list to User
Originally I thought this would be a simple case of arrows travelling from left to right connecting to each activity boxes then drawing arrows back all the way to the where the request started as follows:
User-->Application-->Database
User<--Application<--Database
But then I noticed I see no examples of UML Activity Diagrams with arrows showing the return of anything back to a requester. They all show a one way path to an end point. Is a return always implied if it started with a request to get something? Are return arrows incorrect to use?
Thanks in advance.
Update ---
After some looking around it appears paths are one way. When you reach the end point that is to provide something like a list instead of drawing arrows all the way back to the requester it looks to me like you just add a phrase to the end node saying something like the following: "Return list".
It seems you may not understand the token semantics in activities. An activity diagram does not represent a call stack where one action returns to the previous action. However, one action calling another Call Behavior Action does work like a call stack.
The way an activity diagram works is that each action is a step. A completed action offers tokens to outgoing edges. As soon as any action is offered all the tokens it needs to start, it actually starts. Data and control both work this way.
You can think of each action like a function call. When all tokens are ready on all incoming edges, the function is invoked. When a function finishes, all the outgoing tokens are offered to all enabled outgoing edges. (Outgoing edges are enabled when an optional guard is not false.)
I recommend you read the excellent series by Conrad Bock to be sure you understand how activities work. Otherwise, you are going to frustrate yourself and others trying to make it fit your preconceptions.
There's nothing stopping you from introducing loops in an activity diagram, although for clarity, whenever you've got two or more possible exits from one activity, you should use guards on your connectors to specify under which condition that connector may be followed (eg [x < 10] on one and [x >= 10] on the other).
You can also use decisions (rhomboid) if you want to make the branching condition explicit (eg a decision named "x < 10 ?"); you'd then draw a single connector from the preceding activity to the decision, and the two guarded connectors from the decision.
But from your example it seems you're not drawing a proper activity diagram at all. In an activity diagram, the nodes must be activities -- not actors. There should always be a verb in the name of every activity. So "User requests a product list from Application" is a good activity, but if you've got an activity named "User" you're doing it wrong.

In UML Sequence diagrams, is it possible to model optional external inputs

In UML Sequence Diagrams you have the combined fragment type Alt to branch based on different values for parameters. But let's say that in the middle of your sequence you are waiting for one of two different messages from two different external actors and you shall branch the code depending on which one arrives, what would be the best way to model this? And to make the question a little more challenging, let's throw in the possibility that neither message comes (triggering a timeout).
Without a better solution, I would divide the sequence diagram into multiple sequence diagrams, each new one starting with the one of the two possible messages. Or possibly just go over to state machines. But is their a not too convoluted way that would allow me to show these different cases within one sequence diagram?
I would simply go for the two SDs which you can name accordingly. One should always keep in mind that a SD shall highlight a certain aspect of a complex chain of actions in a system. Trying to put more and more information in a single SD will mess it up and hinder more than it helps.
It is also possible to use diagram fragments which allows navigation through zooming into the two fragments.
The timing diagram will not really help here. You would still need a large alt-fragment to show the sequences depending on which message arrived first.
In addition to the answer I referred in the comment, I made a little sample with a duration constraint for the timeout.
If you have a lot of conditional logic to show Activity Diagrams are an alternative. They do not have object responsibilities or a time axis, but because of this they can freely use two dimensions to show flow control.

Resources