Skip to main content



      Home
Home » Modeling » ATL » ATL Design Patterns
ATL Design Patterns [message #1641415] Sat, 28 February 2015 10:30 Go to next message
Eclipse UserFriend
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.

[Updated on: Mon, 02 March 2015 16:58] by Moderator

Re: ATL Design Patterns [message #1648193 is a reply to message #1641415] Tue, 03 March 2015 15:28 Go to previous messageGo to next message
Eclipse UserFriend
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 15:14 Go to previous messageGo to next message
Eclipse UserFriend
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?

[Updated on: Wed, 04 March 2015 15:15] by Moderator

Re: ATL Design Patterns [message #1651289 is a reply to message #1650380] Thu, 05 March 2015 03:06 Go to previous messageGo to next message
Eclipse UserFriend
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 12:52 Go to previous messageGo to next message
Eclipse UserFriend
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 16:43 Go to previous message
Eclipse UserFriend
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).
Previous Topic:[0..*] multiplicity transformation
Next Topic:startsWith(s : String)
Goto Forum:
  


Current Time: Wed Jul 23 16:42:49 EDT 2025

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

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

Back to the top