BestPractice: How to structure TemplateFunctions

Support questions relating to the actifsource Template Editor

BestPractice: How to structure TemplateFunctions

Postby sip » Thu Sep 08, 2011 11:35 am

One of the many powerful features of actifsource are TemplateFunctions. TemplateFunctions are used to extract template logic into Java Functions for reuse or to improve readability of the template. TemplateFunctions normally are associated to a specific Template, but if many Templates are needed it is good practice to group common functionality into CommonTemplateFunctions.

In real world situations there is an additional usage of TemplateFunctions: TempalteFunctions are used to improve the accessibility of the MetaModel from within the Templates. Useful Function within a Template could for example be:
  • determineType
  • determineImport
  • evaluateTypeAnnotation
  • determineReferencedTypes
  • etc.

Experience shows, that TemplateFunctions grow over time and that the structures choosen in the beginning seem to be less than optimal. Therefor the following recommendation describes a proven structure on how to manage TemplateFunctions:
Structure for TemplateFunctions.png
TemplateFunctions Structure recommendation
Structure for TemplateFunctions.png (13.6 KiB) Viewed 10878 times


I would recommend to start from the beginning with at least three diffenerent Types of TemplateFunctions:
  • Specfic TempalteFunctions: specific functions are used only in the template they are associated with
  • Common TempalteFunctions: common functions are used in some or all templates, but are template related
  • MetaModel TemplateFunctions: meta model functions are used in all templates (and maybe even in the meta model itself) and provide additional value functions on top of the meta model

This recommendation is a good starting point to get the structure of TemplateFunctions right from the very beginning. Also this structure give support in the following areas:
  • Collaboration: responsibility for different TemplateFunctions can be distributed on different roles (e.g. Model-Architect defining the Meta-Model, Application-Architect defining common functions, Application-Developer working on his own specific templates
  • Granularity and Separation of Concern: focus on a limitd scope is posiible
  • Governance and Artefact Life-Cycle: meta model functions will change less frequently than template specific functions

Hopefully this recommendation will help you get the TempalteFunction structure right from the beginning.
sip
 
Posts: 6
Joined: Wed Feb 16, 2011 7:42 am

Return to Template Editor

Who is online

Users browsing this forum: No registered users and 1 guest