Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » RE: OCL Def Operations & Attributes
RE: OCL Def Operations & Attributes [message #54237] Wed, 23 April 2008 14:23 Go to next message
Eclipse UserFriend
Originally posted by: mmelia.computing.dcu.ie

Hi everyone,

I have a question more about the fundamentals of the OCL language, this
probably not the right place for it, but I have always found here a useful
place for some insights.

I am trying to figure out is there any fundamental difference between OCL
defined attributes and operations without parameters (i.e. using the def
in OCL).

Both require a definition in OCL of how they are defined. I presume this
means that as attribute will have to be split into an attribute and
operation at implementation - is this the only difference?

If i define an attribute in OCL is that populated when the context is
instantiated, whereas an operation is only called when used - so is a
performance thing?

Ideas/Comments/clarification requests most welcome.
Mark
RE: OCL Def Operations & Attributes [message #54259 is a reply to message #54237] Wed, 23 April 2008 18:21 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Mark,

Functionally, there is no difference between invocation of an attribute and
a parameterless operation, except the syntactic difference of parentheses.
In particular, both

- "." notation to invoke features of the value
- "->" notation for collection values
- support the @pre notation for precondition-time values

Note that OCL provides no means to define qualifiers for additional
attributes, so the [...] qualifier notation isn't applicable.

It's interesting to note that some languages, such as Eiffel and even BASIC,
subscribe to a principle of "uniform access" in which the parentheses are
not applied to operations that have no parameters, thus making them
indistinguishable from (and sometimes actually interchangeable with)
attributes.

I didn't understand what you meant by splitting an attribute at
implementation.

There is no population of additional attributes. They are, by definition
(pun intended) derived properties. So, in that respect, they can be
considered as being computed values in the same way as operations are. Of
course, this reflects the MDT OCL implementation. A different
implementation may be able to pre-compute values, cache them, or somehow
make attributes more efficient than operations.

HTH,

Christian


Mark Melia wrote:

> Hi everyone,
>
> I have a question more about the fundamentals of the OCL language, this
> probably not the right place for it, but I have always found here a useful
> place for some insights.
>
> I am trying to figure out is there any fundamental difference between OCL
> defined attributes and operations without parameters (i.e. using the def
> in OCL).
>
> Both require a definition in OCL of how they are defined. I presume this
> means that as attribute will have to be split into an attribute and
> operation at implementation - is this the only difference?
>
> If i define an attribute in OCL is that populated when the context is
> instantiated, whereas an operation is only called when used - so is a
> performance thing?
>
> Ideas/Comments/clarification requests most welcome.
> Mark
Previous Topic:Operation return values
Next Topic:NPE using OCL ValidationVisitor
Goto Forum:
  


Current Time: Tue Apr 23 06:58:08 GMT 2024

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

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

Back to the top