Re: A question on OCL



Re: A question on OCL

From: Daniel Jackson <dnj_at_mit.edu>
Date: Thu, 18 Dec 2008 12:48:14 -0500
Message-Id: <26EE2B15-1FBB-4961-8474-4AD075A85A60@mit.edu>
I have to say that I'm surprised by the responses to this question.

It doesn't seem to me to be a tricky case at all. Introducing an  
association strikes me as totally wrong: just consider how that  
association would be designated (if you don't know what a designation  
is, see, eg, http://mcs.open.ac.uk/mj665/Hoare99a.pdf).

I try to resist always saying "just do it in Alloy", but in this case  
I do wonder whether the focus on navigations and contexts in OCL  
creates a problem where there shouldn't be one.

In Alloy, you'd model it like this:

> sig Item {}
> sig Journal, Proceeding extends Item {}
>
> sig Person {}
> sig Faculty extends Person {}
>
> fact {
> 	// if the items of a particular system are all of type 'journal'  
> or 'proceeding',
> 	// then all the persons in this system are of type 'faculty'
> 	Item in Journal + Proceeding implies Person in Faculty
> }
>
> // show me an example
> run {}


Daniel

On Dec 18, 2008, at 3:35 AM, Arnon Sturm wrote:

> All,
>
> I wonder whether it is possible to specify an OCL constraint on two  
> or more model elements which do not have a navigation path among them.
>
> For example, in case of a library system we have two "unrelated"  
> classes: item and person.
> I would like to specify the follwoing constraint: if the items of a  
> particular system are all of type 'journal' or 'proceeding', then  
> all the persons in this system are of type 'faculty'.
>
> For sure, there is the possibility to define a "mediator" class  
> that will create navigation paths. However, we are interested in  
> specifying the constraint without that "mediator" class.
>
> Thanks for your help,
>
> Arnon Sturm
Received on Thu 18 Dec 2008 - 17:48:11 GMT