1
votes

I have an UML state machine diagram, which looks like this:

    +-----------------------------------+
    | A                                 |
    |      +------+  E1   +------+      |  E2   +-----+
o-->|  o-->|  A1  |------>|  A2  |------------->|  B  |
    |      +------+       +------+      |       +-----+
    |                                   |
    +-----------------+-----------------+
                      | E3
                      V
                   +-----+
                   |  C  |
                   +-----+

In reality, composite state A has so many sub-states that I'd like to extract it into a separate diagram. This means that the transition arrow from A2 to B must be cut in half by an exit point.

But where should I put event E2? I think, I should put it on both sides of the exit point, that is, in both diagrams:

High-level diagram (the o-o is the decomposition icon, and (X) is the exit point):

    +-----------+
    |           |
    |           |   E2   +-----+
o-->|     A    (X)------>|  B  |
    |           |        +-----+
    |       o-o |
    +-----+-----+
          | E3
          V
       +-----+
       |  C  |
       +-----+

Low-level diagram:

+------------------------------------+
| A                                  |
|      +------+  E1   +------+  E2   |
|  o-->|  A1  |------>|  A2  |----->(X)
|      +------+       +------+       |
|                                    |
+------------------------------------+

Note that E2 is shown in both diagrams. Unfortunately, I cannot find anything in the UML spec to support this idea. On the contrary, this approach apparently causes a conflict (see section 14.2.3.9.3). But I think there is no conflict here:

  • Both transitions make the system leave state A and enter state B. So they practically form one transition.
  • Both diagrams are easy to understand because both show E2, and the exit point looks like a "gate" between the two diagrams, through which the system's state "moves" from (A, A2) to B. I think it would be confusing to show E2 only on one side of the exit point.
  • If there were another similar transition, for example from A1 to a state D (not shown), then it could be handled the same way, with a second exit point. However in that case the two exit points should be labeled differently (for example: "Exit from A1" and "Exit from A2").

Is this valid UML? If not, how should I solve this problem?

2
I recently was pointed towards omg.org/spec/PSSM/1.0/Beta1 Gates, however, are no mentioned still (they only apply with interactions).qwerty_so
@ThomasKilian Thanks, I wasn't aware of this document. Skimming through it I found some examples, which put the event into the low level diagram only, that is, on the "inner side" of the exit point. When the event arrives, it triggers the transition to the exit point, and the second transition from the exit point is automatic, so there is no need to put the event on it. There is a similar argument in the UML spec, in the last paragraph of section 14.2.3.4.6.kol
@ThomasKilian Quote from this paragraph (emphasis mine): "Exit points are the inverse of entry points. That is, Transitions originating from a Vertex within the composite State can terminate on the exit point. In a well-formed model, such a Transition should have a corresponding external Transition outgoing from the same exit point, representing a continuation of the terminating Transition."kol
I also only skimmed that document. SMs are not my strong side and this document is 1.0 beta. No idea how UML and this doc will be handled by OMG in the future. Maybe they'll decouple SMs (partially) from UML since it's such a complex area.qwerty_so

2 Answers

1
votes

What I'd do in that case is to show A with only A2 inside and the rest left off. A note would tell "this is an excerpt of A".

    +----------------+
    | A (excerpt)    |
    |  +------+      |  E2   +-----+
o-->|  |  A2  |------------->|  B  |
    |  +------+      |       +-----+
    |                |
    +----------------+

Similarly you could leave out the B part by adding notes. Also (if the tool permits) you could add hyperlinks for detail diagrams where appropriate.

1
votes

The event should be placed on the internal party of the transition only.

Exit point is a pseudostate which essentially means it has no internal logic and as soon as the state machine reaches it, it "completes" meaning it is ready for the next transition. In your case you want the transition from A2 to be triggered when E2 occurs. That's why this event has to be placed on the internal part of a transition. On the other hand as soon as the transition reaches exit point (and it "completes") you want an uninterrupted further transition to B so no conditions should be placed on the outgoing (external) transition.

Placing E2 on both "parts" of the transition will change the meaning of the diagram. It would stop transition on the exit pseudostate and wait until another E2 event occurs. Only then (after second E2 event) state machine will reach B state.

Placing E2 on external part will also have a different meaning. The transition to exit point will occur only once the A2 completes (even if E2 occurs earlier) and only transition from exit point will wait for the E2 event. On the other hand the transition to the exit point happens as soon as A2 completes so if it happens any other possible transitions from A2 (e.g. some E4) will no longer be available since the state machine has already left A2 and waits on the exit point (for E2).

You've actually answered your own question in the comments but I hope my word of explanation justifies the full answer.