Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Inheritance in rules [SOLVED]
Inheritance in rules [SOLVED] [message #825499] Tue, 20 March 2012 22:59 Go to next message
Horacio Hoyos is currently offline Horacio Hoyos
Messages: 155
Registered: October 2009
Senior Member

After a few attempts to use inheritance in some ETL and EML rules I completely gave up because I got to many "weird" errors, specially when populating collections. I was in a bit of a hurry and didn't have the time to dig a bit deeper.

I know inheritance can be my friend and save me some time and headaches and I am willing to give it another try. However, in the Epsilon book there is no details regarding inheritance, except for the existence of the extends keyword. For starters I would assume that that a rule can only extend another rule that has the same type of elements in the source parameter. Beyond that I would like to know how does it actually work.

1. Regarding target parameters: do you get a sum of the base and the extended rule, or only the ones from the extended rule? What special considerations must be taken when naming target parameters?

2. Does the base rule always has to be abstract? Probably a clarification of the semantics of the extends operator would come in handy.

3. How does the body of the base rule and the extending rule execute? As before a detailed explanation of the extends semantics would be nice.

4. How all of the above works if you extend more than one rule?

Any other details would be appreciated, for example if in different languages some of the semantics change.

Regards,

Horacio


Horacio Hoyos Rodriguez
EngD Student
University Of York

[Updated on: Tue, 17 April 2012 15:26]

Report message to a moderator

Re: Inheritance in rules [message #826769 is a reply to message #825499] Thu, 22 March 2012 13:38 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris Kolovos
Messages: 886
Registered: July 2009
Senior Member
Hi Horacio,

Please see comments below, with reference to the following example

rule X2Y
transform x : X
to y: Y {

}

rule A2B extends X2Y
transform a : A
to b : B, c : C {

}

> 1. Regarding target parameters: do you get a sum of the base and the extended rule, or only the ones from the extended rule? What special considerations must be taken when naming target parameters?
> 2. Does the base rule always has to be abstract? Probably a clarification of the semantics of the extends operator would come in handy.

For inheritance to work correctly, A must be a subclass of X and B a subclass of Y. If X is abstract, you'll get a B and a C in your target model (b will be processed as y in the body of X2Y). If on the other hand X is not abstract you will get both a Y (or a runtime error if Y is abstract) from X2Y and a B, C from A2B (i.e. X2Y will also execute in its own right and to prevent this from happening it needs to be declared as @abstract)

> 3. How does the body of the base rule and the extending rule execute? As before a detailed explanation of the extends semantics would be nice.

The body of the base rule (X2Y) executes before the body of the rule extending it (A2B)

> 4. How all of the above works if you extend more than one rule?

In this case all base rules are invoked sequentially with the same semantics outlined above.

I hope this helps. When I get a bit of spare time I'll update the book accordingly.

I understand that some of this is confusing due to the lack of compile-time warnings/errors but we're working on this.

Cheers,
Dimitris
Re: Inheritance in rules [message #827101 is a reply to message #826769] Thu, 22 March 2012 22:24 Go to previous messageGo to next message
Horacio Hoyos is currently offline Horacio Hoyos
Messages: 155
Registered: October 2009
Senior Member

Thanks a lot for the information Dimitris.

Horacio Hoyos Rodriguez
EngD Student
University Of York
Re: Inheritance in rules [message #840007 is a reply to message #825499] Mon, 09 April 2012 14:47 Go to previous messageGo to next message
Horacio Hoyos is currently offline Horacio Hoyos
Messages: 155
Registered: October 2009
Senior Member

Hi Dimitris,

Two additional questions:

1. Will inheritance work, using your example, if A is of the same class as X?
2. How does guards work? If rule X2Y has a guard, will rule A2B inherit the guard too?

Regards,

Horacio


Horacio Hoyos Rodriguez
EngD Student
University Of York
Re: Inheritance in rules [message #840035 is a reply to message #840007] Mon, 09 April 2012 15:37 Go to previous message
Dimitris Kolovos is currently offline Dimitris Kolovos
Messages: 886
Registered: July 2009
Senior Member
Hi Horacio,

> 1. Will inheritance work, using your example, if A is of the same class as X?

Yes, it should work.

> 2. How does guards work? If rule X2Y has a guard, will rule A2B inherit the guard too?

I'd expect it too.

Cheers,
Dimitris
Previous Topic:installing epsilon on galileo
Next Topic:Problem with providing variable to template
Goto Forum:
  


Current Time: Thu Oct 23 20:14:06 GMT 2014

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

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