1

Is it possible to reuse an operation call of a class as transition in an UML diagram of Sparx Enterprise Architect (I've got version 9)? If yes, how do I do that?

It's possible to use it as action in an activity diagram and as message in an object diagram, but I can't figure it out for the state machine. I wish there was more integration for software developers...

Furthermore, I wish I could set a state in the diagram as special state of a class instance (class instance == object).

falkb
  • 1,294
  • 11
  • 35
  • "message in an object diagram"? Do you mean sequence diagram? I have never seen messages in object diagrams. – sergej Nov 06 '15 at 11:16
  • I don't understand the sentence about "special state of a class instance". Could you clarify please? – sergej Nov 06 '15 at 11:18
  • I want to demonstrate via UML how a programmed state machine for a handshake transfer protocol works. The states are actually variable values in the source code of certain C++-objects which are instances of C++-classes. The transitions are the member functions of the classes which leads to such new states. I want to be tide to the code, and want to reuse the class member functions which were scanned from the source code. – falkb Nov 06 '15 at 11:33
  • On object diagram can have directed associations between objects where I can add a message to it which can be defined as certain operation-call of a C++ class member function. This way an object diagram is quite similar to a sequence diagram but doesn't have a timeline. – falkb Nov 06 '15 at 11:35
  • Do you mean [communication diagram](https://en.wikipedia.org/wiki/Communication_diagram)? – sergej Nov 06 '15 at 11:41
  • [UML Protocol State Machine Diagrams](http://www.uml-diagrams.org/protocol-state-machine-diagrams.html) – sergej Nov 06 '15 at 11:58
  • @sergej: Not communication diagram, this one: http://www.sparxsystems.com.au/resources/uml2_tutorial/uml2_objectdiagram.html – falkb Nov 06 '15 at 12:28
  • And what are the messages in these diagrams? – sergej Nov 06 '15 at 12:34
  • @sergej: The association lines between the objects can be set to be a "message". Look here: http://www.tiikoni.com/tis/view/?id=325a7cb and http://www.tiikoni.com/tis/view/?id=641a410 – falkb Nov 06 '15 at 12:47
  • You can double-click the message and select the operation in the "message" menu. But such diagrams are commonly called communication (not object) diagrams. – sergej Nov 06 '15 at 13:03
  • @sergej: in Sparx EA, a communication diagram type is just a subset of an object diagram type with reduced functionality. But generally you're right. – falkb Nov 06 '15 at 13:09

1 Answers1

3

Is it possible to reuse an operation call of a class as transition in an UML diagram ...?

Yes. In the state machine diagram: Open the transition properties, enable "Effect is Behavior" and select the operation from the browser.

enter image description here

It's possible to use it as action in an activity diagram ...

Yes. Add a 'Call Operation' action to the activity diagram. Goto, "action properties" -> "Call" and select the operation from the "Behavior:" menu.

enter image description here

... and as message in an object diagram ...

Yes. Draw a link between the objects on the object diagram, right-click the link and select "Add message from ... " (where "..." is the desired direction). Double-click the message and select the operation from the "Message:" drop-down list.

enter image description here

sergej
  • 17,147
  • 6
  • 52
  • 89
  • Great! Do you also know how to show in the diagram how the operation-call leads to a new state where a certain attribute has a certain new value? – falkb Nov 06 '15 at 11:04
  • @falkb The question is not clear to me. Shall the operation be executed during transition or shall the transition be triggered by the operation? – sergej Nov 06 '15 at 11:13
  • That's the same for me. The reason for a new state is why a certain operation (C-function) was called in the program (maybe with a special parameter value). The state is usually stored in certain variables, e.g. flags will be set or a enum-typed state-variable is set to a new value. – falkb Nov 06 '15 at 11:24
  • Not my expertise, but the point in time is determined by entry/exit/do (stereotypes). – qwerty_so Nov 06 '15 at 11:27
  • 1
    @falkb *Transition-behavior* and *Transition-trigger* are two different things in UML state machines, it's not the same. Take a look at [this](http://stackoverflow.com/a/32404829/2020827). – sergej Nov 06 '15 at 11:54
  • Do you know how to display values of attributes (of objects) as they define the new state after a transition? – falkb Nov 06 '15 at 13:12
  • 1
    Aaah, got it by myself! Context menu on a state in the state machine diagram -> click on "attributes..." -> browse and choose 'type' from model tree, and set name and initial value. Now that's it. :-) – falkb Nov 06 '15 at 13:18