Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL expression for return type
OCL expression for return type [message #56653] Sun, 25 May 2008 10:32 Go to next message
Timothy Marc is currently offline Timothy MarcFriend
Messages: 547
Registered: July 2009
Senior Member
Hi all,

i've read the parts of OCL Specification that deals with the return type
of an Operation. IMHO, this section is a bit confusing, so i think i
didn't get it at all.

I have an Operation foo in class A, which should return the property
name of that class. Now, i want to add this as a constraint into my uml
model with value:

context core::A::foo:String() result = self.name

Does this mean the same as in-code:

class A{
String name;
String foo(){
return this.name;
}
}

Thx

-tm
Re: OCL expression for return type [message #56761 is a reply to message #56653] Mon, 26 May 2008 13:22 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, tm,

This is one of those points where the OCL and UML specifications don't
agree on the definition of operation bodies.

The OCL specification of an operation body condition constraint is:

context core::A::foo() : String
self.name

In UML, all constraints are required to be boolean-valued, which is why
UML requires the "result = " part that makes it look like a
post-condition constraint.

HTH,

Christian

On Sun, 2008-05-25 at 12:32 +0200, Timothy Marc wrote:
> Hi all,
>
> i've read the parts of OCL Specification that deals with the return type
> of an Operation. IMHO, this section is a bit confusing, so i think i
> didn't get it at all.
>
> I have an Operation foo in class A, which should return the property
> name of that class. Now, i want to add this as a constraint into my uml
> model with value:
>
> context core::A::foo:String() result = self.name
>
> Does this mean the same as in-code:
>
> class A{
> String name;
> String foo(){
> return this.name;
> }
> }
>
> Thx
>
> -tm
Previous Topic:OCL dependency not being picked up.
Next Topic:Re: [OCL] AstNode - startPosition is a transient attribute
Goto Forum:
  


Current Time: Thu Aug 29 15:10:16 GMT 2024

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

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

Back to the top