Re: OCL 2.0 metamodel (Re: instance OCL constraints?)



Date view Thread view Subject view Author view Attachment view

From: Jos Warmer (J.Warmer@klasse.nl)
Date: Fri 12 Mar 2004 - 07:21:57 GMT


Hello,

An <<invariant>> constraint must by definition hold for all instances
of the class involved.  Never use an explicit forAll in this case.

You can simply attach a constraint in a notebox to an Instance
modelelement.. If you do _not_ give this the <<invariant>> stereotype,
this constraint holds for the instance modelelement  only.

Jos Warmer

At 08:39 PM 3/11/2004 +0100, SainTiss wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>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
>instance?
>
>Does this make sense, or did I get it wrong here?
>
>Thanks,
>
>Hans
>
>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)
>
>Capitalism:
>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
>2LIC INF
>UA 2003-2004
>-----BEGIN PGP SIGNATURE-----
>Version: GnuPG v1.2.3 (GNU/Linux)
>
>iD8DBQFAUMBiXlnUYIbmLOQRAkFcAJ4rlcE93+RvYsFx7qDyHaUPJAYXEwCfX7Gc
>BlCSA/IJVmU1wW6LCcv9mVE=
>=mHPB
>-----END PGP SIGNATURE-----
>
>
>
>
>To remove yourself from this list please mail puml-list-request@cs.york.ac.uk
>with a message containing the word "unsubscribe".


_____________________________________________________
Klasse Objecten         tel     : +31 (0)35 6037646
Chalonhof 153           fax     : +31 (0)35 6037647
3762 CT Soest           email   : J.Warmer@klasse.nl
The Netherlands         internet: http://www.klasse.nl

Date view Thread view Subject view Author view Attachment view