RE: A question on OCL



RE: A question on OCL

From: Arnon Sturm <sturm_at_bgu.ac.il>
Date: Thu, 18 Dec 2008 23:57:43 +0200
Message-Id: <20081218215858.E0B1D146BAD@smtp2.bgu.ac.il>
Thank you all for the discussion.
 
As Earl suggested I will try to expand my question. The intention of my
question is related to profiles (as Jorg guessed).
 
I would like to restrict stereotypes within a profile and specify
dependencies among these.
 
The allInstances solution suggested seems a good one. Yet I am not clear,
what the context of that invariant is? do we need a context for that kind of
constraints? what is the meaning in that case?
 
 
Arnon
 

  _____  

From: puml-list-request@cs.york.ac.uk
[mailto:puml-list-request@cs.york.ac.uk] On Behalf Of Waldin, Earl
Sent: Thursday, December 18, 2008 8:38 PM
To: puml-list@cs.york.ac.uk
Subject: RE: A question on OCL


Wow, it's amazing to see this much activity on PUML!
 
Perhaps the misunderstanding has to do with (mis)understanding the original
statement of the problem. Like Daniel, I see nothing in the problem
statement that would indicate any kind of relationship between journals,
proceedings and persons: 
 
  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'.
 
Reading an author-publication relationship or some other hidden relationship
into this is going beyond the problem as stated. My original OCL constraint,
although syntactically far less elegant than that in Alloy, says the same
thing as Daniel's:
 
  Item.allInstances()->forAll(i | i.oclIsKindOf(Journal) or
i.oclIsKindOf(Proceeding)) implies Person.allInstances()->forAll(p |
p.oclIsKindOf(Faculty))
 
I introduced the second version with a Library as context because the
statement mentions a library system and the above seems to me to be a
statement about a library system and not about the relationship between
types of publications and persons, although given the brevity of the
statement I could be wrong. There is also the question of what the statement
intends with "if the items of a particular system".  Just what is this
"particular" system? Is it relevent? If so then Arnon can expand his
question to include a more precise description of the problem and we can
stop speculating.
 
So let's not read too much into this simple example!
 
    -Earl
 

-----Original Message-----
From: puml-list-request@cs.york.ac.uk
[mailto:puml-list-request@cs.york.ac.uk] On Behalf Of Daniel Jackson
Sent: Thursday, 18 December, 2008 18:48
To: puml-list@cs.york.ac.uk
Subject: Re: A question on OCL


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 - 21:59:14 GMT