Search code examples
umlactivity-diagram

How do I model UML Activity that calls operations from the same class?


Suppose I have some Class (specialization of BehavioredClassifier) with three operations A(), B() and C() and the operation C just calls operation A and then B. UML's CallOperation action (see 16.3.3.1 Call Actions) requires target object which in this case will be a context object in UML parlance as described in section 13.2.3.4 Behaviored Classifiers of UML Specification:

a Behavior that is the ownedBehavior of a BehavioredClassifier has that BehavioredClassifier as its context... If a Behavior has a context , then an execution of the Behavior always has an associated context object that is an instance of the context BehavioredClassifier (as long as that BehavioredClassifier is instantiable)

UML Activity diagram will look rather ugly due to Read self activity (see 16.4.3.4 Read Self Actions in UML Specification): enter image description here

I have a feeling that I read somewhere that Read self can be omitted under some circumstances and target may be assumed to be context object in that case.

Is there such clause in UML documentation?


Solution

  • I couldn't find such clause in UML Specification, but found the solution, described below.

    First so called ActionInputPin is to be used for target. According to paragraph 16.2.3.3 Pins:

    An ActionInputPin provides values by executing another Action. When an Action is enabled by other means, the fromActions on any ActionInputPins owned by the Action are also enabled. The fromActions must execute before the Action owning the ActionInputPins, and the outputs of the fromActions are placed in the corresponding ActionInputPins. The process recurs on any ActionInputPins of the fromActions. In the case that ActionInputPins are used for all inputs, this forms a tree structure that is an Action model of nested expressions, bottoming out at Actions that have no inputs (such as ReadVariableActions or ReadSelfActions)

    Then Annex B: UML Diagram Interchange of UML Specification that

    ... enables interchange of the purely graphical aspects of UML models that modelers have control over, such as the position of shapes on a diagram and line routing points (UML DI). This information must be interchanged between tools to reproduce UML diagrams reliably.

    states in paragraph B.4.3 Activity Diagram Labels that

    ActionInputPins with fromActions that are ReadSelfObjectActions may be shown in a shorthand notation that shows only the ActionInputPin and nearby the string “self” interchanged as a UMLLabel with the ReadSelfObjectAction as modelElement.

    The above clause is illustrated in table Table B.1 UML Shapes as follows:

    enter image description here

    Thus the model in question is transformed into the neat version shown below:

    enter image description here