Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Operation return values
Operation return values [message #54130] Sat, 19 April 2008 07:12 Go to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
Hey,

some weeks ago I asked on the UML2 Newsgroup about how to return multiple values
from a class operation. The consensus was, that through the "only one return
parameter" constraint, I should use "out" or "inout" parameter direction kinds.

I now read in the OCL spec, (Appendix A, 1.4.4 Operations):

DEFINITION A.3 (OPERATIONS)
[...]
The name of an operation is determined by the symbol w. The first parameter tc
denotes the type of the class
instance to which the operation is applied. An operation may have any number of
parameters but only a single
return type. In general, UML allows multiple return values. We currently do not
support this feature in OCL.

I am confused by the "In general, UML allows multiple return values". Does this
refer to out, and inout parameters? Or did UML1.4 allow multiple "return"
parameters, and they changed it for 2.0?

Felix
Re: Operation return values [message #54157 is a reply to message #54130] Sat, 19 April 2008 16:03 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Felix,

In UML 2.0, Operation supported any number of return parameters. The
Operation metaclass had a returnResult association end with multiplicity
[0..*].

In UML 2.1, that was changed to restrict operations to a single return
result. One of the reasons for this is that multiple return results were
inconsistent with the TypedElement::type property that Operation inherits.
There was no means indicated by which to define a type for such operations.

OCL 2.0 had enough difficulty catching up to UML 2.0 (which, in some cases,
it still hasn't done) but now it is behind again, since UML 2.1 has been
released. So, as far as the OCL spec knows, UML Operations *do* have
multiple "return" parameters.

As I recall, there has been discussion about mapping operations with
out/inout parameters and/or multiple returns to Tuple types. I don't think
this discussion went anywhere, though it is really the only construct that
OCL has which could deal with this situation.

In the end, the OCL spec doesn't support out/inout parameters and multiple
returns, and neither does the MDT implementation. However, using OCL, you
can define "additional operations" that return multiple values by
explicitly declaring their type to be a Tuple type. e.g.:

context EPackage
def: summarize() : Tuple{name : String, type : String,
attrs : Integer, opers : Integer} =
self->eClassifiers->collect(c : EClassifier |
if c.oclIsKindOf(EClass) then
Tuple{name = c.name, type = 'Class',
attrs = c.oclAsType(EClass).eAllStructuralFeatures->size(),
opers = c.oclAsType(EClass).eAllOperations->size()}
else
Tuple{name = c.name, type = 'Data Type', attrs = 0, opers = 0}
endif)

Cheers,

Christian


Felix Dorner wrote:

> Hey,
>
> some weeks ago I asked on the UML2 Newsgroup about how to return multiple
> values from a class operation. The consensus was, that through the "only
> one return parameter" constraint, I should use "out" or "inout" parameter
> direction kinds.
>
> I now read in the OCL spec, (Appendix A, 1.4.4 Operations):
>
> DEFINITION A.3 (OPERATIONS)
> [...]
> The name of an operation is determined by the symbol w. The first
> parameter tc denotes the type of the class
> instance to which the operation is applied. An operation may have any
> number of parameters but only a single
> return type. In general, UML allows multiple return values. We currently
> do not support this feature in OCL.
>
> I am confused by the "In general, UML allows multiple return values". Does
> this refer to out, and inout parameters? Or did UML1.4 allow multiple
> "return" parameters, and they changed it for 2.0?
>
> Felix
Previous Topic:About OCL name expressions
Next Topic:RE: OCL Def Operations & Attributes
Goto Forum:
  


Current Time: Mon Dec 22 18:43:21 GMT 2014

Powered by FUDForum. Page generated in 0.03705 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software