|(no subject) [message #716879 is a reply to message #716858]
||Thu, 18 August 2011 16:34
| Ed Willink
Registered: July 2009
> here a naïve beginners OCL question:
Not thant naive.
> Can I also use it to specify operations like a model object's
No. Simplistically, OCL is a side effect free language and constructing
an object has side effects. You need a model transfoprmation language
extension to give OCL the ability to mutate a model.
However, the side effect of construction is localized, so there is a
proposal to generalize the Tuple construction syntax to support
> In OCL I can state:
> "Object A has to contain two instances of Object B with the names 'X'
> and 'Y'."
> Can I also use this to enforce this rule by construction?
> E.g. when EMF creates a new instance of Object A, it automatically
> creates two instances of B where one gets the name 'X' and one gets
> the name 'Y' and moves them into A?
No. As above.
No. Clearly simple equality constraints can be analyzed to produce
constructional assignments, but arbitrary constraints such as, there
shall be 26 children, each with an uppercase distinct name of unit
length, in ASCII order, may require intractable symbolic analysis to
produce an efficient solution, even if one exists.
> So far in EMF I used ResourceSetListener to react on model changes and
> then add some stuff automatically. However, these rules then are
> hardcoded in Java and I'd like to have them on the higher abstraction
I'd be inclined to go for defining derived properties in OCL and perhaps
using caches so that you evaluate lazily on demand rather than eagerly
on change, which may have race condition issues. There could be OCL to
Java code generation for Juno, so your higher level of abstraction
should become much less costly.
> Can I at least use the MDT OCL for live validation? I.e. if A already
> has two Objects B, tooling like the generated EMF sample editor will
> not offer the operation of adding another B?
It's only software; of course it's possible. But you would need to
upgrade the generated EMF sample editor to produce a candidate new state
for every possible change if you want OCL constraints of arbitrary
complexity. This approach was used in conjunction with OCL analysis to
exploit the combination of fast modern computers and efficient optimized
OCL update to perform brute force analysis of thousands of quickfix
suggestions so as to offer a short list of practical suggestions to
resolve refactoring issues.
More practically you may want to find a simple declarative (OCL) model
of the constraints in your system and then use M2M to transform these
constraints into a form that different tools can consume, so a Java
callable filter on generated EMF sample editor menu entries would be
Powered by FUDForum
. Page generated in 0.02009 seconds