Template System

Topic updated 20-6-2007

The GenWise Template System introduces a unique, powerful programming paradigm. Source code generation is performed by collections of specialized templates that are hierarchically organized. All templates interact and cooperate, each having their specific generation tasks.

When generating software with GenWise, program functionality is determined by the following activities:

1.Selecting template types and creating template instances.
2.Configuring templates, both at the global level and at detailed levels.
3.Enhancing template output with custom source code.

 

The GenWise approach shifts development efforts from editing source code files (whether created from scratch or with traditional code generators) to working with templates, configuring them and enhancing their output.

 

Template format

GenWise Templates are .NET classes in assemblies loaded by GenWise Studio. GenWise Templates are registered into GenWise Studio using the Template Factory. The plug-in structure makes the GenWise Template System extendable.

 

Hierarchical structure

Templates are organized in a hierarchical way and delegate generation tasks along this hierarchy. A complete hierarchically organized set of templates is called a Template Chain. At the top of the hierarchy in Template Chains are Project Templates.

 

Template interaction

There are different Template Types working together in every GenWise project. Some templates work on the level of single project items. Other templates interact with multiple project items, adding functionality by changing their source code generation behaviour. A good example of this are Extension Templates.

 

Template Options

Main project items have Template Options Pages that give access to their own template options and of their child templates. Every template defines a set of template options to configure its source code generation behaviour. Source code gets conditionally generated depending on template options, preventing generation of unnecessary code, and tailoring the application to its tasks.

 

Global template configuration

A strong feature of the GenWise Template System is its distinction between Global Template Configuration and template instance configuration. Every instance of a certain template uses globally set template option values, unless these are overruled at the instance level. As a result, you can control many aspects of the generation process in centralized way, while having detailed control over single cases where needed.

Most templates define a large part of their template options as globally configurable within the project. In the Global Template Configuration screen you can view and edit all global template options within the project.

 

 

Example of Template Options

main_templatesystemconfigscreenexample

When the mouse is moved over a template option the Options Help pane displays a short explanation for it.

Notice that colors are used to communicate the status of individual template options. At the bottom there is a legend that helps you to remember the meanings of the colors when the mouse is moved over them. The colors convey status information as listed below.

Option using global value
The template option has a global value and is currently using this global value. The value of the option can be changed locally.

Option using custom value
The template option has a global value, but it is currently using a local value. It can be reset to its global value using its context menu (right-click the option to access its context menu).

Calculated Option
The value of this option is currently determined (calculated) by the template. The calculated value is dependent on the configuration of other templates, and may change if this external template configuration changes.

Calculated option overridden
The template option has an associated calculated value which has been overridden by the user. The option can be reset to use its calculated value from its context menu (right-click the option to access its context menu). When a calculated value has been overridden by the user then the value is not dependent on external template configuration and will not react to changes therein.