Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » MVC + JET
MVC + JET [message #55951] Thu, 22 January 2009 13:52 Go to next message
Youmm P. is currently offline Youmm P.Friend
Messages: 140
Registered: July 2009
Senior Member
Hello,

do you have some references or some tips to enforce a strict separation
between the model, the logic and the templates (MVC pattern or MVC-like)?

Thanks in advance.
Re: MVC + JET [message #56004 is a reply to message #55951] Thu, 22 January 2009 19:58 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Hi:

Here is a basic pattern:

1) templates that generate content correspond to MVC views. These are
templates that are referenced from tags such as <ws:file>

Rules for view templates (VT):

VT1) Avoid doing calculations in the template. Many values may be
pre-calculated by using the <c:set> tag to create 'derived' attributes on
model elements. Such tags are executed in the controller
VT2) The most comment tags in view templates should be <c:get>,
<c:iterate> and conditionals (<c:if>, <c:choose>, ...)

2) templates that orchestrate the creation of contents correspond to the MVC
controller. The main.jet template is the primary controller, although it may
delegate to other templates via <c:include>

Rules for controller templates (CT1):

CT1) Perform any model manipulation and value pre-calculation in the
controller and not view templates. This is generally done by traversing the
model (c:iterate tags) and by using c:set to calculate values.

3) Models. A JET transformations input is a model. However, it may not be
exactly what you need for efficient template execution. You typically may do
one or both of the following (in the controler)

a) Calculate values and store their results as annotations on the
model via <c:set>. These annotations appear to the JET XPath engine as
normal attributes.
b) load or create additional models via tags such as <c:load> and
<c:loadContents>.

Other best practice rules:

1) In view templates, replace whole language tokens. That is:

Don't do: public int get<c:get select="camelCase($e/@fieldName)"/>();
Do do: public int <c:get select="$e/@getter"/>();

(of course, there will be a c:set tag something like this in the
controller (main.jet):
<c:set select="$e" name="getter">get<c:get
select="camelCase($e/@fieldName)"/></c:set>

2) Try to avoid Java code in templates. If you much do Java code, put most
of the code in a utility class, rather than directly in the template.

Hope this is a start.

I've created an JET FAQ page with this information. Please feel free to
share you experiences there:

http://wiki.eclipse.org/M2T-JET-FAQ/Are_there_equivalents_to _the_MVC_pattern_for_JET_transformations%3F

Paul
Re: MVC + JET [message #56428 is a reply to message #56004] Mon, 26 January 2009 10:39 Go to previous message
Youmm P. is currently offline Youmm P.Friend
Messages: 140
Registered: July 2009
Senior Member
Thanks you very very much for this information of high value!
Previous Topic:generating java code from UML2 activity diagrams
Next Topic:Re: JET1 Editor for EMF Codegen template extensions
Goto Forum:
  


Current Time: Wed Sep 25 03:06:11 GMT 2024

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

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

Back to the top