Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL Inheritance(Behavior of OCL when Stereotypes are hierarchical )
icon5.gif  OCL Inheritance [message #1470827] Wed, 12 November 2014 17:11 Go to next message
Rishi Kanth is currently offline Rishi KanthFriend
Messages: 18
Registered: October 2014
Junior Member
Hi,

I have created a UML Profile with the following structure :- two stereotypes A1 and A2, where A1 is extension of UML::Assocication and A2 is derived from A1(or A1 is a generalization of A2).

I have defined two OCL constraints OC1 (applied to A1) as
self.base_Association.endType.getAppliedStereotypes()->asBag().name = Bag{'ST1','ST1'}
or
self.base_Association.endType.getAppliedStereotypes()->asBag().name = Bag{'ST1','ST3'}

and OC2 (applied to A2) as
self.base_Association.endType.getAppliedStereotypes()->asBag().name = Bag{'ST2','ST3'}

(ST1, ST2 and St3 are stereotypes from another profile that extend UML:Class)

As A2 is derived from A1, how do the OCL constraints behave. From my experimenting and observation, A2 inherits the OCL from A1 and combines them as OC2 AND OC1.

Please correct me if I am wrong and also, if any other information on this topic.

Thanks,
Rishi


Re: OCL Inheritance [message #1470966 is a reply to message #1470827] Wed, 12 November 2014 19:33 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6044
Registered: July 2009
Senior Member
Hi

Constraints should apply to derived classs.

You can regard the composition as a conjunction, if you like.

[Efficient tooling should realize them as a conjunction to exploit CSE
and avoid duplicate/premature evaluation.]

Regards

Ed Willink

On 12/11/2014 17:11, Rishi Kanth wrote:
> Hi,
>
> I have created a UML Profile with the following structure :- two
> stereotypes A1 and A2, where A1 is extension of UML::Assocication and A2
> is derived from A1(or A1 is a generalization of A2).
> I have defined two OCL constraints OC1 (applied to A1) as
> self.base_Association.endType.getAppliedStereotypes()->asBag().name =
> Bag{'ST1','ST1'}
> or
> self.base_Association.endType.getAppliedStereotypes()->asBag().name =
> Bag{'ST1','ST3'}
> and OC2 (applied to A2) as
> self.base_Association.endType.getAppliedStereotypes()->asBag().name =
> Bag{'ST2','ST3'}
>
> (ST1, ST2 and St3 are stereotypes from another profile that extend
> UML:Class)
>
> As A2 is derived from A1, how do the OCL constraints behave. From my
> experimenting and observation, A2 inherits the OCL from A1 and combines
> them as OC2 AND OC1.
> Please correct me if I am wrong and also, if any other information on
> this topic.
>
> Thanks,
> Rishi
>
>
>
Re: OCL Inheritance [message #1470979 is a reply to message #1470966] Wed, 12 November 2014 19:48 Go to previous messageGo to next message
Rishi Kanth is currently offline Rishi KanthFriend
Messages: 18
Registered: October 2014
Junior Member
Hi Ed,

Thanks for the reply. Can it be possible to treat/convert the combination to a union (OR).
Re: OCL Inheritance [message #1471555 is a reply to message #1470979] Thu, 13 November 2014 06:57 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6044
Registered: July 2009
Senior Member
Hi

Absolutely not. Makes no sense.

context Bicyle
inv HasPedals: ...
inv HasSaddle: ...

Are you happy to have only one constraint satisfied?

Regards

Ed Willink

On 12/11/2014 19:48, Rishi Kanth wrote:
> Hi Ed,
>
> Thanks for the reply. Can it be possible to treat/convert the
> combination to a union (OR).
Re: OCL Inheritance [message #1472017 is a reply to message #1471555] Thu, 13 November 2014 14:25 Go to previous messageGo to next message
Rishi Kanth is currently offline Rishi KanthFriend
Messages: 18
Registered: October 2014
Junior Member
Yes, I thought so, but was compelled to ask the question(fundamentals of OOP).

I can have either OC1 or OC2 satisfied
Re: OCL Inheritance [message #1472071 is a reply to message #1472017] Thu, 13 November 2014 15:23 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6044
Registered: July 2009
Senior Member
Hi

Only fundamental in that it is fundamentally wrong.

Inheritance in which the derived is not a specialization can be very
troublesome. Google the Liskov Substitution Principle.

Regards

Ed Willink


On 13/11/2014 14:25, Rishi Kanth wrote:
> Yes, I thought so, but was compelled to ask the question(fundamentals of
> OOP).
> I can have either OC1 or OC2 satisfied
Re: OCL Inheritance [message #1472097 is a reply to message #1472071] Thu, 13 November 2014 15:46 Go to previous messageGo to next message
Rishi Kanth is currently offline Rishi KanthFriend
Messages: 18
Registered: October 2014
Junior Member
Hi Ed

Thanks.
When you say "Are you happy to have only one constraint satisfied? " what you mean is if OC2 is only satisfied for A2 rather than both OC1 and OC2.

Please let me know.
Re: OCL Inheritance [message #1472112 is a reply to message #1472097] Thu, 13 November 2014 16:00 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6044
Registered: July 2009
Senior Member
Hi

My example was for a bicycle so that is what I meant.

I see no value in this discussion. Please consult an OO newsgroup if you
want to discuss these issues.

Regards

Ed Willink


On 13/11/2014 15:46, Rishi Kanth wrote:
> Hi Ed
>
> Thanks. When you say "Are you happy to have only one constraint
> satisfied? " what you mean is if OC2 is only satisfied for A2 rather
> than both OC1 and OC2.
> Please let me know.
>
Previous Topic:validating OCL constraints
Next Topic:OCL Association Constraint
Goto Forum:
  


Current Time: Wed Sep 26 07:16:03 GMT 2018

Powered by FUDForum. Page generated in 0.01963 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top