In, out, inout, returns the direction of the parameter in UML

As I read the following concepts through the UML specification promoted by OMG 2.5 (Beta), like:

in: Indicates that parameter values ​​are being transmitted using the caller.

inout: Indicates that the parameter value is passed in by the caller and then returns to the caller.

out: indicates that the parameter values ​​are passed to the caller.

return: indicates that parameter values ​​are passed as return values ​​back to the caller.

Does this mean that "in" is a call by value and "inout" as a call by reference?

Could you clarify each of these concepts?

+6
source share
4 answers

• in - Input parameter (cannot be changed).

• out - output parameter (can be changed to transmit information to the caller).

• inout - input parameter that can be changed.

• return - The return value of the call.

+2
source

Calling by reference is one of the possible implementations of inout and out , yes.

Remember that UML describes behavior in a neutral language. It depends on the implementation of this interface in real language to determine what it means.

In a language such as Ada, with in , out and in out level parameters at the language level, this can be expressed directly in the language, and the compiler can decide where the link or copy is the best implementation. In a language such as Python, where all parameters are passed by reference (view), this designation of intent at the UML level does not lead to a difference at the implementation level. And in a language such as C, with explicit pointer types and all parameters passed by value, these intentions expressed in UML turn into explicit references to the addresses and markups of the pointer.

In other words, the short answer is “yes, that's about what it means, but it may not be what it does.”

+1
source

The key point to remember about UML is that it is designed as universal, it must be independent of the implementation platform. In particular, it is PIM, a platform-independent model. Therefore, it is incorrect to use the semantics of the implementation of a particular platform, such as "by value" and "by reference".

Now in practice, the definition of this specific domain semantics is one task of the project architect, and in many cases the semantics that you mentioned are valid, but this is not always the case.

Managed Architecture Model (MDA) plus Platform Profile = Platform Specification .

0
source

When we look at the official UML specification, we find a slight change:

in: Indicates that parameter values ​​are being transmitted using the caller.

inout: Indicates that parameter values ​​are passed to the caller and (possibly different) values ​​passed to the caller.

out: indicates that the parameter values ​​are passed to the caller.

return: indicates that parameter values ​​are passed as return values ​​back to the caller.

And it contains a note: no more than one parameter can be marked as a return parameter.

I could not find any further definitions / clarifications on this ParameterDirectionKind enumeration.

those. UML does not want to point this further. And, of course, he does not indicate any of them as passing by reference or passing by value.

0
source

All Articles