Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [M2T] How to achieve a general goal
[M2T] How to achieve a general goal [message #62289] Fri, 05 June 2009 09:52 Go to next message
Miguel Angel Garcia de Dios is currently offline Miguel Angel Garcia de Dios
Messages: 22
Registered: July 2009
Junior Member
Hi everyone,
I have read as much as I could and now, I had several generic doubts.
I have a .ecore model. This .ecore model is a metamodel of GUI's and, as
instances of it, I create models (like instances of the .ecore model)
using EMF as usual.
My goal is to transform that models, instances of the .ecore model,
representing differents GUIs, to Java interfaces (using SWING, AWT,
SWT...) AUTOMATICALLY.
I think M2T handles this kind of purposes.
I think in two ways:
1.- Directly create a "JET transformation" from my models to my desired
..java clases and make it run.
2.- If it exists, use a pre-defined "JET transformation" that takes as
input models which are instances of a certain Java metamodel (obviuously
represented as .ecore or equivalent, also if it is exists too) and
automatically generates de desired Java code. In that case, I would not
have to use JET technology but only a QVT model transformation from GUI
models to JAVA models.

I hope you could point my job in the right direction.
Thank you!
Re: [M2T] How to achieve a general goal [message #62313 is a reply to message #62289] Fri, 05 June 2009 17:56 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven Efftinge
Messages: 1769
Registered: July 2009
Senior Member
Hi Miguel,

I'ld recommend to use code generation.
Model transformation to the target platform model can become very
complicated. It's not that model transformation is inherently
complicated, but a Java meta model is very complicated, at least if it
not only covers the coarse grained concepts but also includes statements
and expressions.
IMHO generating code using a template language is easier, more readable
and maintainable, because we know and thing in the concrete syntax of
Java, not in its abstract syntax (aka meta model).

Cheers,
Sven

Miguel Angel Garcia de Dios schrieb:
> Hi everyone,
> I have read as much as I could and now, I had several generic doubts.
> I have a .ecore model. This .ecore model is a metamodel of GUI's and, as
> instances of it, I create models (like instances of the .ecore model)
> using EMF as usual.
> My goal is to transform that models, instances of the .ecore model,
> representing differents GUIs, to Java interfaces (using SWING, AWT,
> SWT...) AUTOMATICALLY.
> I think M2T handles this kind of purposes.
> I think in two ways:
> 1.- Directly create a "JET transformation" from my models to my
> desired .java clases and make it run.
> 2.- If it exists, use a pre-defined "JET transformation" that takes
> as input models which are instances of a certain Java metamodel
> (obviuously represented as .ecore or equivalent, also if it is exists
> too) and automatically generates de desired Java code. In that case, I
> would not have to use JET technology but only a QVT model transformation
> from GUI models to JAVA models.
>
> I hope you could point my job in the right direction.
> Thank you!


--
Need professional support on Xtext or Xtend?
Mail to: xtext (at) itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: [M2T] How to achieve a general goal [message #62337 is a reply to message #62313] Sat, 06 June 2009 15:20 Go to previous messageGo to next message
Krzysztof Kowalczyk is currently offline Krzysztof Kowalczyk
Messages: 113
Registered: July 2009
Senior Member
Sven Efftinge pisze:
> Hi Miguel,
>
> I'ld recommend to use code generation.
> Model transformation to the target platform model can become very
> complicated. It's not that model transformation is inherently
> complicated, but a Java meta model is very complicated, at least if it
> not only covers the coarse grained concepts but also includes statements
> and expressions.
> IMHO generating code using a template language is easier, more readable
> and maintainable, because we know and thing in the concrete syntax of
> Java, not in its abstract syntax (aka meta model).
>
> Cheers,
> Sven

Hi,

IMHO it is not that much complicated to use M2M, but one need some
helper functions, and I am not aware of any Ecore Java model with java
code generation (so I did one myself).

I am using Modisco J2SE metamodel
(http://www.eclipse.org/gmt/modisco/technologies/J2SE5/) that represent
resolved java syntax (it can read Java code, and I can generate almost
exactly the same code, but all the types corresponding to names are
known). I did write Xpand templates from this model to Java.

Pros:
- You use type safe transformations
- Some transformations are actually easier in M2M way, as you collect
some informations in many places and put them to output model
- You can alter the output model in any way afterwards.

Cons:
- it is really low level model
- it is a bit complicated (UML is many times more complicated!)
- using M2T is more productive in typical cases

Nevertheless probably M2T would better in that use case.

Eventually I would propose to check the work around
http://www.eclipse.org/pmf/ You may find it interesting.

Ps. If you want to use both M2M and M2T you may eventually implement
same queries in both technologies. AFAIK JET, Acceleo and QVT, ATL have
no integration. On other hand there is Xpand with Xtend, so you can use
one query language to do M2M and use it in your M2T templates. IMO it is
more productive in most cases, but you pay a price - Jet is faster than
Xpand and ATL is faster than Xtend.

That is my personal opinion I am not connected to any of those
technologies ;).


Regards,
Krzysztof Kowalczyk
Re: [M2T] How to achieve a general goal [message #62361 is a reply to message #62337] Mon, 08 June 2009 17:03 Go to previous message
Miguel Angel Garcia de Dios is currently offline Miguel Angel Garcia de Dios
Messages: 22
Registered: July 2009
Junior Member
Ok, I think that the best option in my opinion is using JET but, Do
anybody know about a tutorial about the general steps for creating those
tamplates from EMF models? I mean, a tutorial for the language to be
used, or and simple example that, from a EMF model generates a simple
Java Code using the information about that model?
I am looking for a tutorial of this type but I am not being able to
understand the general steps and structure.
Than you for your answers.
Krzysztof Kowalczyk wrote:
> Sven Efftinge pisze:
>> Hi Miguel,
>>
>> I'ld recommend to use code generation.
>> Model transformation to the target platform model can become very
>> complicated. It's not that model transformation is inherently
>> complicated, but a Java meta model is very complicated, at least if it
>> not only covers the coarse grained concepts but also includes
>> statements and expressions.
>> IMHO generating code using a template language is easier, more
>> readable and maintainable, because we know and thing in the concrete
>> syntax of Java, not in its abstract syntax (aka meta model).
>>
>> Cheers,
>> Sven
>
> Hi,
>
> IMHO it is not that much complicated to use M2M, but one need some
> helper functions, and I am not aware of any Ecore Java model with java
> code generation (so I did one myself).
>
> I am using Modisco J2SE metamodel
> (http://www.eclipse.org/gmt/modisco/technologies/J2SE5/) that represent
> resolved java syntax (it can read Java code, and I can generate almost
> exactly the same code, but all the types corresponding to names are
> known). I did write Xpand templates from this model to Java.
>
> Pros:
> - You use type safe transformations
> - Some transformations are actually easier in M2M way, as you collect
> some informations in many places and put them to output model
> - You can alter the output model in any way afterwards.
>
> Cons:
> - it is really low level model
> - it is a bit complicated (UML is many times more complicated!)
> - using M2T is more productive in typical cases
>
> Nevertheless probably M2T would better in that use case.
>
> Eventually I would propose to check the work around
> http://www.eclipse.org/pmf/ You may find it interesting.
>
> Ps. If you want to use both M2M and M2T you may eventually implement
> same queries in both technologies. AFAIK JET, Acceleo and QVT, ATL have
> no integration. On other hand there is Xpand with Xtend, so you can use
> one query language to do M2M and use it in your M2T templates. IMO it is
> more productive in most cases, but you pay a price - Jet is faster than
> Xpand and ATL is faster than Xtend.
>
> That is my personal opinion I am not connected to any of those
> technologies ;).
>
>
> Regards,
> Krzysztof Kowalczyk
Previous Topic:[XPand] how can I access XPand documentation.
Next Topic:JET: navigating to references for EMF-models
Goto Forum:
  


Current Time: Mon Oct 20 21:12:39 GMT 2014

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

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