purpose of tokens in Activity diagrams of Uml 2.5

帅比萌擦擦* 提交于 2019-12-11 12:49:07

问题


UML specs 2.5 says:

The effect of one ActivityNode on another is specified by the flow of tokens over the ActivityEdges between the ActivityNodes.

But above definition is obscure; specially because tokens are not explicitly modeled in an Activity.

After reading 15.2.3.3 Activity Edges section of specifications, I think purpose of them is:

to capable the diagram to describe it may wait for other token or refuse flow instead of entering next node immediately

Is it true? Also is it the only purpose of tokens? If it is true, why we do not use a decision node with a condition and a end flow node for showing refusing flow under that condition instead of token and guards? Or grouping information into larger objects node which carries all necessary data instead of using weight?


回答1:


Activity diagrams and state machines are both derived from Petri nets. Giving a full description would blow this answer, so I try to boil it down.

A token is, so to say, a bit of information. It's atomic and can not be split. Rather it is created from a "big bang" out of an event which is defined in the context (shown usually by a large black dot). It travels along InformationFlow connectors (eventually blocked by guards where it has to wait) to nodes. Nodes have 1 to many InformationFlow connectors. A node becomes active when at all of its incoming InformationFlow connectors a token has arrived. When the node finalizes it sends single tokens along all its outgoing InformationFlow connectors (at least UML actions do so which is called implicit fork). There are special nodes like fork and merge which behave a bit different (see the specs). Finally tokens can fall in a sink (usually a circle with a fat dot inside) where they just vanish as they appeared.

So from a single token (not going to explain the details/issues of multiple start points here) emerging from a start node this token travels in the net, eventually creating other tokens all circulating until (usually) all tokens have gone to sinks. During that the net is said to be active.

tl;dr No, your assumption is not correct that way.



来源:https://stackoverflow.com/questions/52159321/purpose-of-tokens-in-activity-diagrams-of-uml-2-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!