2
votes

I've stuck with a small problem designing a class diagram in UML Designer: I can't figure out how to specify a return type for an operation. There is no information about it on UML Designer home site and it's guides. I've tried to explore operation and parameter settings but have found nothing (new parameter creation picture, parameter settings picture, advanced operation settings picture). Can anyone help me, please?

2

2 Answers

2
votes

I didn't find a way to define a return value type explicitly, but the following workaround:

  1. Add the operation to the interface/class, i.e. "calculate" (you can't specify a return value). The operation is now rendered as "calculate()".
  2. Now click on the label of the operation in the class diagram to activate the direct edit tool for the operation.
  3. Type " : ReturnValueType" at the end of the operation name right after the closing parenthesis and press [ENTER] --> "operation() : ReturnValueType[1]" should be rendered now ([1] stands for the cardinality of the return value ... means it is mandatory ;-) )
  4. Now you've defined a special operation parameter, a return value parameter, implicitly. You can verify this by double-clicking the operation to open the edit window and check the icon of your new defined parameter: it's an icon with an arrow pointing left-down away.
  5. If you add another parameter to this operation by clicking the [+] symbol, you would define an input parameter of the operation, indicated by an arrow pointing into the icon.

Btw, I didn't find a difference between the two types of parameters (input vs. return value) in the edit window of an operation parameter, so I think this workaround is the only way to define a return value type of operation.

1
votes

Add a parameter to the function and select Return in the Direction item under its properties.

  1. From the Model Explorer, find the function for which you want to define a return value. Model Explorer
  2. Select the parameter prepared as a return value from among them.
  3. There is a direction in the advance of the property tab. Properties

You get the following result:

Class Diagram