Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Question about constraints vs. invariants
Question about constraints vs. invariants [message #687031] Mon, 23 May 2011 19:55 Go to next message
Eclipse UserFriend
Originally posted by:

Hi,

The EMF delegates mechanism provides two ways of validating the
EObjects, constraints and invariants. AFAIU, invariants are meant to be
small and quick checks that can happen often while constraints are meant
to implement more global checks. What I don't understand is how this has
lead to the particular implementation of these. In particular, invariant
are implemented using modelled EOperation with a specific signature. Why
has this particular implementation been chosen and how can the arguments
of the EOperation be used in the body?

Regards,

Hallvard
Re: Question about constraints vs. invariants [message #687032 is a reply to message #687031] Mon, 23 May 2011 20:11 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Hallvard

As validated constraints, there is little difference between Ecore
invariants and Ecore constraints., Both should be invoked during validation.

The significant difference is that an Ecore invariant is callable
whereas an Ecore constraint is not. This may be useful from a more
sophisticated environment that allows selective invocation and
re-invocation of constraints.

The arguments can only be used from Java bodies.

Regards

Ed Willink

On 23/05/2011 20:55, Hallvard Trætteberg wrote:
> Hi,
>
> The EMF delegates mechanism provides two ways of validating the
> EObjects, constraints and invariants. AFAIU, invariants are meant to
> be small and quick checks that can happen often while constraints are
> meant to implement more global checks. What I don't understand is how
> this has lead to the particular implementation of these. In
> particular, invariant are implemented using modelled EOperation with a
> specific signature. Why has this particular implementation been chosen
> and how can the arguments of the EOperation be used in the body?
>
> Regards,
>
> Hallvard
Re: Question about constraints vs. invariants [message #687033 is a reply to message #687032] Mon, 23 May 2011 21:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by:

On 23.05.11 22.11, Ed Willink wrote:
>
> The significant difference is that an Ecore invariant is callable
> whereas an Ecore constraint is not. This may be useful from a more
> sophisticated environment that allows selective invocation and
> re-invocation of constraints.

Yes, that seems like a useful property of invariants.

> The arguments can only be used from Java bodies.

What can the arguments be used for in that case? Provide better
messages? I'm implementing support for Javascript-based delegates
(similar to the OCL support), so I wonder if there are special use cases
I should support.

Hallvard
Re: Question about constraints vs. invariants [message #687034 is a reply to message #687033] Tue, 24 May 2011 05:12 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

>> The arguments can only be used from Java bodies.
>
> What can the arguments be used for in that case? Provide better
> messages? I'm implementing support for Javascript-based delegates
> (similar to the OCL support), so I wonder if there are special use
> cases I should support.
>
As I wrote that I considered adding a magic 'oclContextTuple' to access
the context from OCL, but very low priority and certainly not at RC2.

The 'DiagnosticChain diagnostics' argument is needed if you take control
since it is the diagnostic output 'stream'. If you have a conventional
control flow then it is used automatically.

The 'Map<Object, Object> context' argument allows arbitrary objects and
values to be passed in, and in some cases updated. A common use is
provision of a SubstitutionLabelProvider to pretty print the
descriptions of interesting objects in diagnostics.

Regards

Ed Willink
Previous Topic:deleting eobject
Next Topic:(no subject)
Goto Forum:
  


Current Time: Thu Apr 25 04:06:53 GMT 2024

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

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

Back to the top