Activity with several initial nodes: must all of them be started for the Activity to begin?

Viewed 156

What if the activity has one initial node and one input parameter node? Can the activity start before there is an available object at the input node? In the example from https://de.wikipedia.org/wiki/Aktivit%C3%A4t_(UML) attached, could the "boil water (Wasserkochen)" activity begin, without any spaguetti being available? enter image description here

3 Answers

The activity in your example will start once the Start Node emits a token. It is irrelevant whether the spaghetti are aleady present at the object node. Only when the start condition is met and the start node has emitted a token the activity will start with the first action. Only then the action "Spaghetti einfüllen" will wait for the spaghetti - or use them if already present.

Now, why is the action "Spaghetti einfüllen" hanging upon non present spaghetti? Simply, it has two tokens that must arrive in order to start. One is that coming from "Wasser kochen" and the other is the object "Spaghetti [roh]". Only if both are present, the action will start. And of course, if only the spaghetti are there, the second token from the previous action "Wasser kochen" must also be there.

You can read all the gory details of when actions start or not in paragraph 16.3.2.1 on pp. 441 of UML 2.5.

Further, as @GeertBellekens pointed out, there is paragraph 15.5.3.1 on p. 401 which states

An ExecutableNode shall not execute until all incoming ControlFlows (if any) are offering tokens. That is, there is an implicit join on the incoming Control Flows. Specific kinds of ExecutableNodes may have additional prerequisites that must be satisfied before the node can execute.

An activity is not responsible of its start, its execution start is done from outside of it. Even a possible precondition is not part of the activity itself but inherited from behavior.

From formal/2017-12-05 15.3.3.1 Initial Node :

If an Activity has more than one InitialNode, then invoking the Activity starts multiple concurrent control flows, one for each InitialNode.

From formal/2017-12-05 15.2.3.6 Activity Execution:

When an Activity is invoked, any values passed to its input Parameters are put in object tokens and placed on the corresponding input ActivityParameterNodes for the Activity (if an input parameter has no value, a null token is placed on the corresponding ActivityParameterNode).

When an Activity is first invoked, none of its nodes other than input ActivityParameterNodes will initially hold any tokens.

From your edit you speak about ActivityParameterNode, while your input parameter node has no value the execution started (the action Wasserkochen is done) but it is not possible to execute the action Spaghetti einfullen

While there already are some answers I think it is good to add some context.

The activity is a description of behaviour. The thing is this behaviour doesn't exist in some void. Instead, especially when with input and output parameters, it is a part of some larger behaviour (indicated as a special action type - activity call). Now to better understand, what is going to happen, you need to look at the two types of activity edges.

The activity edges control the flow of an activity. There are two types of edges - control flows and object flows. When a node other than fork finishes execution it offers exactly one control token, that then follows one of the available control flows. In a properly modeled activity there is no ambiguity which control flow should be followed.

In addition to the control flows there may also be object nodes. These are used to show how objects (e.g. documents) are passed across the activity. There may be many significant objects inside the activity and some (or even all) of them may have their dedicated object flows. So UML introduces the concept of an object flow parallel to the control flow. Unfortunately there are two confusing things here. First, the object flow an the control flow use exactly the same notation - a solid line with an open arrow at the end. The only difference is that object flows start and end at object nodes while control flows start and end at control nodes. For a novice it can be confusing, as supposedly similar line can have two different meaning. But there is more.

Sometimes the main (control) flow of an activity is controlled... by objects. Typically there is just one object produced by one action and passed to the next one. The next action takes is activated only once the object is delivered to it. So both control flow and object flow has to happen at the same time. The problem is on the activity diagram it can be depicted by showing only an object flow. The parallel control flow is then implicit.

How does it impact your case?

If a call to your activity is a part of a larger process and the only incoming flow is an object flow to input pin named Spaghetti [roh/raw] then your Start node will be triggered (produce a control token) only when there is an object available on Spaghetti [roh/raw] object node. In such case after water is cooked (Wasser kochen/cook water action completes) there will always be spaghetti to be added in Spaghetti einfüllen/add spaghetti.

However, if you have a separate control flow it might happen that the control token will arrive when there is no object token available on Spaghetti [roh/raw]. According to the specification it means there will be a null token placed on that object node. In other words, the activity will execute, but the amount of spaghetti available will be null. So the water will still be boiled and then the Spaghetti einfüllen/add spaghetti action will be executed. How is it going to handle "faulty" object token is up to the action. It can simply treat it as a 0 amount of spaghetti and continue (so you keep cooking for 10 minutes and then produce another null token at the output parameter) or it can be handled by some kind of exception. Either case, the Wasser kochen/cook water action will last only until its internal behaviour is executed so no, you will not end up in boiling water until it's all evaporated, unless you allow that inside exception handling for null spaghetti [roh/raw] token received exception inside the Spaghetti einfüllen/add spaghetti action.

Related