Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » ATL Design Patterns
ATL Design Patterns [message #1641415] Sat, 28 February 2015 15:30 Go to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

Hello all,

I've started a page on the Eclipse wiki about ATL-specific design patterns:

https://wiki.eclipse.org/ATL/Design_Patterns

So far, I've added three patterns that I found useful in my experience:


  • Object indexing
  • Many-To-One
  • Many-To-Many


If you found other patterns for yourself, please add them to this topic! We may then include them on the wiki.


Cheers,
Dennis

[Updated on: Mon, 02 March 2015 21:58]

Report message to a moderator

Re: ATL Design Patterns [message #1648193 is a reply to message #1641415] Tue, 03 March 2015 20:28 Go to previous messageGo to next message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
Hi,

how about manually programmed tracing for called-rules?
Maybe it is to0 simple..but if you get familiar with the thisModule.resolveTemp()
operation you don't want to miss it in a called rule.

To implement a trace manually , just use Maps!

Here a helper for the trace:
helper def : elementsMap : Map(IN!in_element, OUT!out_element) = Map{}; 


Just add your references to the transformed elements in the do-section of a rule:

do {
thisModule.elementsMap  <- thisModule.elementsMap->including(in_element, out_element);
}


This map might be quit usefull if you need to access the trace elsewhere.

~Alex
Re: ATL Design Patterns [message #1650380 is a reply to message #1648193] Wed, 04 March 2015 20:14 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

Thanks! It's a simple pattern, which is good. It also allows you to customise tracing any way you like.

For safety reasons (not overwriting existing traces, not generating duplicate elements) you may also want to look at unique lazy rules, which can also take primitive type elements as input these days, e.g.:

unique lazy rule StringToEClass {
  from s : String
  to t : ECORE!EClass (
    name <- s)
  do {
    thisModule.elementsMap  <- thisModule.elementsMap->including(s, t);
    t; -- return value
  }
}


In EMFTVM, you don't even need to record your own traces for unique lazy rules. You can use the special, three-parameter version of resolveTemp() listed under https://wiki.eclipse.org/ATL/EMFTVM#ATL_Module_operations .

I propose to add your pattern as Custom Tracing, is that ok for you?


Cheers,
Dennis

[Updated on: Wed, 04 March 2015 20:15]

Report message to a moderator

Re: ATL Design Patterns [message #1651289 is a reply to message #1650380] Thu, 05 March 2015 08:06 Go to previous messageGo to next message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
Hi,

of course you can add the "pattern" to the current wiki!

Best regards
Alex
Re: ATL Design Patterns [message #1763370 is a reply to message #1651289] Sun, 14 May 2017 16:52 Go to previous messageGo to next message
neda karshenas is currently offline neda karshenasFriend
Messages: 10
Registered: February 2016
Junior Member
hi Dennis
i'm need a project about design pattern. Do you have a project object indexing?
if yes please send to me.
thank's
Re: ATL Design Patterns [message #1763799 is a reply to message #1763370] Fri, 19 May 2017 20:43 Go to previous message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

Unfortunately, the project where I applied these design patterns isn't open source. I nearly needed the object indexing pattern for my TTC 2015 solution, but the metamodel provided inverse properties for everything (this is a typical use case: computing the inverse of a model element property).

Cheers,
Dennis
Previous Topic:[0..*] multiplicity transformation
Next Topic:startsWith(s : String)
Goto Forum:
  


Current Time: Thu Apr 25 00:13:23 GMT 2024

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

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

Back to the top