OCL 2.0 metamodel (Re: instance OCL constraints?)

Date view Thread view Subject view Author view Attachment view

From: SainTiss (saintiss@arklinux.org)
Date: Thu 11 Mar 2004 - 19:39:14 GMT

Hash: SHA1

Hi again,

I just had a look at the OCL 2.0 submission, to check how exactly the 
metamodel represents a constraint.
If I interpreted this correctly, e.g. for an invariant, the only demand wrt 
the OclExpression is that its type is Boolean, but not that it should apply 
to all instances of its contextual classifier. From that, I conclude that, if 
one wants the constraint to apply to all instances, a "forAll" iterator 
construct should be stored explicitly. Is that correct? (if not, then I guess 
the spec should state somewhere that every OCL implementation should make 
sure every constraint is applied to all instances of the contextual 
classifier by itself, but I couldn't find any such statement).

If my assumption is correct, then I guess this brings us one step closer to my 
original question, as it is then possible to apply a constraint to just one 
instance. Only question remaining is then: how to specify exactly which 

Does this make sense, or did I get it wrong here?



On Thursday 11 March 2004 17:35, SainTiss wrote:
> Hi,
> unless I'm severly mistaken, the normal way of going about with OCL is
> specifying certain constraints on a model, which must hold for each
> instance of that model. More specifically, if the constraints only apply to
> e.g. one class of the model, then accordingly, they must hold only for all
> instances of that class. The "context" specification determines this scope.
> So a typical example would be a class diagram with certain constraints on
> the classes involved. An instance of that class diagram could be seen as an
> object structure, i.e. a collaboration of objects, each object being an
> instance of a class defined in the class diagram.
> Now suppose one would use an UML collaboration diagram to describe a
> snapshot of such an object structure. Then it would be handy to be able to
> use OCL to describe a constraint which must hold for a certain object in
> the
> collaboration. Is this possible?
> I've been thinking a bit about this, and I guess it comes down to
> specifying a constraint of which the context is not "all instances of a
> certain type" but "just one instance". AFAIK the "context" keyword always
> needs a type, and not an instance, so I guess it won't work that way, but
> maybe something like a helper function which would take the one instance as
> a parameter for example?
> Thanks in advance,
> Hans

- -- 
Ark Linux - Linux for the Masses (http://arklinux.org)

You don't have any cows. The bank will not lend you money to buy cows, 
because you don't have any cows to put up as collateral.

Representative Democracy:
You have two cows. Your neighbors pick someone to tell you who gets the milk. 

In a world without walls and fences, who needs windows and gates?

Hans Schippers
UA 2003-2004
Version: GnuPG v1.2.3 (GNU/Linux)


Date view Thread view Subject view Author view Attachment view