Search code examples
parametersumlreturndirectionout

How to understand "return" as parameter direction?


In UML2.3 superstructure document, section 7.3.42 ParameterDirectionKind, there is a Description for the enumeration of the literal values:

in/inout/out/return

It is easy to understand "in" and "inout" from implementation perspective.

In C++ for example, "in" can be implemented in two ways:

foo( CString strParam )
bar( const CString& strParam )

"inout" can be also implemented in two ways: (reference & pointer)

foo( CString* pParam )
bar( CString& strParam)

Now comes to my question:

  1. What does "return" mean? (I'm talking about "return" direction for a parameter, not return type for an operation/method)

    Are there any language support this direction of parameter? What is the code looks like.

    If no language support it, how to use it conventionally?

  2. What is the difference between "return" and "out"?

  3. Any implementation code for "out" direction of a parameter?

In my opinion, whenever we are talking about a parameter, there must be a caller call this function with an argument assigned to the parameter. Is this statement correct?

Then based on the parameter's direction, it could be in/inout/out/return. My question is: what does "return" direction mean? There must be a reason for the OMG to put this type in the document that I did not figure out.

From UML2.3 Superstructure 7.3.42

return:Indicates that parameter values are passed as return values from a behavioral element back to the caller.

Thank you in advance


Solution

  • in UML, the "return parameter" is what is returned and can have only one. Think of it from the perspective of being inside the method (not from the perspective of real life language design as you know it). The return parameter is what the entity passes to what invoked it.