How to show duplicate actions in an activity diagram? - uml

I'm working on an activity diagram that has a decision node. First action is "review application" then it goes into the decision node. This splits into accepted or rejected. On both cases, I need to add "Update audit trail" and "notify user" actions. And then the flow goes to the final node.
The "Update audit trail" and "notify user" actions will use the same method in the application, but obviously behave differently depending on the decision.
0-->Review_Application--> <> --> ??
The question is, after the decision node can I duplicate the last two actions twice for each decision flow and then join them to the final node. Or should I use a join node to after the decision node and not duplicate the last two actions? What is the recommended way to achieve this?
Many Thanks

My preference is to avoid fork/join unless there's real concurrency. So I would not use fork or join bars unless you had real parallel activities.
The left one makes more sense. Why?
In this case, the arguments inside the "Notify User" activity will be different.
They're two instances of the same type of activity. Someone may implement them as one method with different argument values.
You can clarify this by naming the activities with a name that clarifies what's different about them.
Your two "update audit trail" can both connect directly to the terminating node. Don't use a Join. Just connect to the next activity or state node.

Related

Can one Activity Diagram Depict only One process

I am Working on a project for Orders data visualization Dashboard.
This is the use case Diagram:
Currently I'm working on the activity diagram and my question is: Can the Manager and the Shipper login into the system and initiate their own activities in the same diagram?
An activity diagram "specifies behavior by sequencing subordinate units". It can perfectly have several initial nodes, e.g. one for Admin and one for Manager or Shipper. And when the activity is invoked, all those initial nodes would be activated at the same time, starting each a concurrent flow, each being performed at its own pace.
But this makes only sense if the Manager's actions and the Shipper's actions are really related, concurrent and somehow synchronized. E.g. every time an Admin login is performed, a Manager login would be expected.
If the Manager flow as well as the Shipper flow are both independent and in reality unsequenced, you should use separate activity diagrams. In this case, trying to squeeze them into a single diagram could even be misleading.
Additional remarks, unrelated to your question:
Typically you'd have a separate activity diagram for each use case. It's not an obligation, but it's a common practice to describe what happens for a specific use-case. In your case, it would mean that only the Ship Order and the Update product stock would be in a situation where actions could be interdependent.
When activity diagrams are used to design systems, it shows in principle what happens inside the system. The actors are outside the system. So the partitions (columns) would in principle not show what an actor does, but what the system does in relation with an actor. Of course, if you use activity diagrams for process modeling, it would be a different story.
Yes, they can. With each InitialNode a flow begins and the tokens run down the actions independently. Probably at a certain time you will have some synchronization between both (this is not mandatory but otherwise it would probably rather pointless to have two independent flows in the same diagram). In that case you either have a MergeNode (bar) to wait for both tokens to arrive or an action has two incoming edges waiting for both tokens in order to commence.

UML Activity Diagram - join

i have following Activity Diagram:
I need to solve the upper section of diagram.
The "false" branches of decision and their join before getting to "Show form" action, it my solution ok or should this be solved some other way ( all three arrows to the show form or some diamond join) ??
One glaring problem is that “Show Form” deadlocks. It can never start because all tokens must arrive on all arrows before it can start. 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. I recommend you read the excellent series by Conrad Bock to be sure you understand how activities work.

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.

UML: activity diagram control flow

I have found in internet the following activity diagram:
I can't understand why from Recieve order action there are two control flows (to Ship order and Bill customer). Are they parallel? Then why there is NOT fork. How to understand this diagram? Please, explain.
This is simply a bad example.
Judging from the context there should be a fork to indicate that both Ship order and Bill customer should happen in parallel.
Then there should be a Join before Send confirmation to indicate that both flows should have finished before the Send confirmation is executed.
It's perfectly valid UML 2. The first action requires no tokens, so it can start immediately. When the first action finishes, it offers tokens to two other actions and they can start. The last action cannot start until all required tokens are offered. When the last action is done, the containing activity is also done.
Forks just copy tokens. Joins just merge tokens. Thus, forks and joins are often unnecessary.
Please see Conrad Bock's excellent series of articles on activity diagrams in the Journal of Object Technology.
I did not check if this is a recent amendment to the UML specification but the current version 2.5 (chapter 15.2.3.2) states (emphasis set on my own):
As an ActivityNode may be the source for multiple ActivityEdges, the same token can be offered to multiple targets. However, the same token can only be accepted at one target at a time (unless it is copied, whereupon it is not the same token, see ForkNodes in sub clause 15.3 and ExecutableNodes in sub clause 15.5). If a token is offered to multiple ActivityNodes at the same time, it shall be accepted by at most one of them, but exactly which one is not completely determined by the Activity flow semantics. This means that an Activity model in which non-determinacy occurs may be subject to timing issues and race conditions. It is the responsibility of the modeler to avoid such conditions in the construction of the Activity model, if they are not desired.
From that point of view, I would argue that #Jim L.'s answer might be deprecated. I assume that, at least in the current version of UML, the diagram in question does not reflect the modeler's intention. A fork seems to be not only the clean way but the only right way to go, now.

How to merge decision/fork nodes in UML

I have the below UML activity diagram for a shopping cart use case. It has several decision and fork nodes but there are no corresponding join/merge nodes. Could you please show me:
how to correct the diagram by introducing the merge/join nodes.
how to modify the diagram so that a customer can repeat the process (of adding more products to the shopping cart).
Thank you.
You should look into the token concept. It is introduced in petri nets and also used in the UML activity diagram.
Decision nodes produce one token only, i.e. they follow just one outgoing path. To merge such paths, of which only was is followed, you can use a merge node. Which just looks like a reversed decision node and is able to consume exactly one token. A diamond with multiple incoming edges.
If you use a parallelization node to start concurrent execution paths, you have multiple tokens leaving the parallelization node. To merge these kind of paths, you can use a synchronization node, it looks like a reversed parallelization node and has to consume one token per incoming edge.
(source: amg at www.lcc.uma.es)
Do you have an initial activity element anywhere? Makes it a bit easier to read. To your question, the merge should be used as opposed to having multiple connectors coming into the same activity. For instance, "Acknowledge Msg" should have a merge above it that the other branches can flow into.
As for how to make it repeatable, you may want an "Add to Cart" action, and prior to a "Checkout" action, have a Decision with guards for "Shopping Complete" (which goes to the Checkout action) and "Continue Shopping" (which goes back to "Enter Product #").

Resources