2
votes

TL;DR: How should I represent a UML Transition (see next line) in a UML Object Diagram?

event(event_parameters) [guard_condition] / doStuff()

In my BSc thesis project, I am working with UML StateMachines (behavioural, no protocol SMs). Besides the State Machine Diagram representation, I require Object Diagrams.

So far, however, I have not managed to accurately represent transitions. I'd like to be able to show transitions that have a trigger (event), a guard (constraint) and/or behaviour.

I have searched for related questions (this one comes close, but doesn't provide the exact information I'm looking for), as well as read the relevant parts of the UML Superstructure, but still can't quite figure it out.

So far, I've created an Object Diagram based on the state S1 (and all transitions) shown in the State Machine Diagram below. I should note that I have only added events, since guard and behaviour are giving me similar problems (and would clutter the diagram).

State Machine Diagram containing state S1

State Machine Diagram containing state S1

(incorrect) Object Diagram for S1, including all transitions (I'm assuming that at least the SignalEvent instances are (somewhat) incorrect.)

(incorrect) Object Diagram for S1, including all transitions (I'm assuming that at least the SignalEvent instances are (somewhat) incorrect.)

3
I couldn't directly post pictures because I do not have 10 rep. yet, so changed them to links.tjalling
@David Thank you for changing the links back to picturestjalling

3 Answers

1
votes

State machines show how the system reacts to stimuli, while object diagrams represent a specific state of the system at one point in time. Since object diagrams are static, you cannot represent a state machine transition in them. What you can do is create two object diagrams, and telling that the second diagram is the result of applying the specified state transition to the first diagram. But I don't think that there is a formal way to do this.

1
votes

The UML2 meta model is quite complicated. If you want to have it UML2 compliant I suggest the following: Use a tool with the org.eclipse.uml metamodel which is capable to draw state diagrams. An open source one would be Topcased. A complete list can be found here (but not all of them support state diagrams).

After you have drawn your diagram, save it as .uml file. The file contains XMI and is quite human readable. It is a little easier if you open it with the EMF viewer (installed in Topcased), just use "Open With" in it).

If you don't care about UML2 compliance and just want something similar to your diagram above this solutions would result in a more complex object diagram than necessary.

0
votes

The current UML specification (see https://www.omg.org/spec/UML/) has the answer. It has a diagram that depicts the abstract syntax of state machines. Combined with the abstract syntax of Triggers, the spec provides enough information to create an object diagram.