Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » The quality of an xPand template
The quality of an xPand template [message #501159] Tue, 01 December 2009 11:12 Go to next message
Wafi Dahman is currently offline Wafi Dahman
Messages: 15
Registered: November 2009
Junior Member
hi to all..

how can I evaluate the quality of my xPand template file?
are there any quality aspects or criteria that must/should be considered?


Thanx in-advance
Re: The quality of an xPand template [message #501248 is a reply to message #501159] Tue, 01 December 2009 16:26 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten Thoms
Messages: 354
Registered: July 2009
Location: Dortmund
Senior Member

Hello Wafi,

Xpand templates should be in first order easy understandable and well structured. To achieve this you can follow some guidelines:

1) Don't let template files get too large. Delegate to other files, split per artifact, create common template code etc.
2) Don't let DEFINEs get too large. Delegate to other definitions.
3) Don't use too much logic in Xpand.
- check model for consistency before Xpand execution. No need to handle special situations that come from inconsistent models in Xpand code (like "if feature something is not set then create special code, otherwise take information from the model").
- Use M2M transformation to autocomplete the model according to conventions (e.g. set the name of unnamed association ends)
- Use Xtend functions for non-trivial evaluations
4) Don't use LET, prefer Xtend functions.
5) Don't use PROTECT when the generation gap pattern can be applied
6) Use the Xpand profile (available from 0.8.0-M3) to identify performance bottlenecks. It can also be useful to identify unused templates and Xtend functions.
7) Optimize the template for readability of the template, not of the generated code. Use Code formatters as postprocessors when possible.
8) Set the file encoding as project-specific setting. Good choices are ISO-8859-1 or UTF-8.
9) Don't use too deep loops or conditions. Delegate to sub-templates.
10) Whenever some expression is used several times, create an Xtend function.
11) Don't use too many EXTENSION declarations in the template. Use a template specific Xtend file and reexport required extensions.

I hope this helps you a bit.

Kind regards,
~Karsten


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @kthoms
Blog : www.karsten-thoms.de

[Updated on: Tue, 01 December 2009 16:26]

Report message to a moderator

Re: The quality of an xPand template [message #501504 is a reply to message #501248] Wed, 02 December 2009 15:27 Go to previous messageGo to next message
Wafi Dahman is currently offline Wafi Dahman
Messages: 15
Registered: November 2009
Junior Member
This is very nice.. Thank you alot
Re: The quality of an xPand template [message #507678 is a reply to message #501159] Thu, 14 January 2010 11:08 Go to previous messageGo to next message
Wafi Dahman is currently offline Wafi Dahman
Messages: 15
Registered: November 2009
Junior Member
hello Karsten,

i would like to use these notes in my thesis.. Can I write them as they are without citing, or can you give me a reference to cite them? I am not sure if inserting a cite to this forum is correct?

[Updated on: Thu, 14 January 2010 11:09]

Report message to a moderator

Re: The quality of an xPand template [message #509590 is a reply to message #507678] Sat, 23 January 2010 12:21 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten Thoms
Messages: 354
Registered: July 2009
Location: Dortmund
Senior Member

I'm not sure whether it is formally correct to cite a forum post, you'll have to clarify with your mentor. I'm afraid I cannot give you another link.

~Karsten


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: The quality of an xPand template [message #510657 is a reply to message #509590] Thu, 28 January 2010 09:26 Go to previous message
Wafi Dahman is currently offline Wafi Dahman
Messages: 15
Registered: November 2009
Junior Member
may be you can list them in your blog..?
Previous Topic:Any trigger action for M2T?
Next Topic:[Acceleo] Suggestion : icons for autocompletion
Goto Forum:
  


Current Time: Sun Oct 26 08:33:30 GMT 2014

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

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