Introduction to CodeGen

CodeGen

Introduction to CodeGen

 

CodeGen is a tool that software developers who are working in a Synergy development environment (Synergy/DE) can use to generate source code. That code is often Synergy Language code, but could also be source code for some other programming language. CodeGen is not restricted to producing code for any particular development environment or programming language.

Of course you can’t just use CodeGen to generate any piece of source code that you can imagine. Before code can be generated a developer must declare the rules that define how a given piece of source code should be created. These rules are defined in template files. CodeGen interprets the code and instructions that a developer has defined in a template file in order to produce useful output.

Defining rules in a template file is only part of the story though. To be really useful CodeGen also needs to have another source of information that defines a context for what is to be generated.

Most software applications revolve around the collection, presentation, manipulation and storage of data. Tat data is ultimately stored in some type of persistent storage such as in a a collection of data files, or in the tables of a relational database. When developers work on a particular piece of source code what they are often doing is combining the knowledge that they have about an application's data (meta-data) with rules (or "business logic") in order to create source code that addresses a particular requirement. CodeGen does the same thing.

When developers work in Synergy/DE they have access to an excellent source of meta-data that is called the Synergy/DE Repository. A Synergy repository holds extensive information about the data structures used by a software application, and the attributes of those data structures. A repository can also contain information about the relationships between the various data structures, and even about underlying data storage mechanisms. A Synergy/DE repository is a very rich source of meta-data, and is the primary source of meta-data used by CodeGen.

For developers who use the Synergy/DE UI Toolkit to present their application's user interface there may also be a second source of meta-data called Window Script files. In some situations CodeGen can also make use of the meta-data contained within these files also.

It’s all about meta-data! In a nutshell, CodeGen takes information about a data structure and combines that information with rules that have been defined in a template file in order to create some useful output text.

Basic Principles

Each time a developer uses CodeGen to generate code, they typically provide two primary pieces of information:

1.A source of meta-data, usually the name of a repository structure.

2.The name of one or more template files which define the rules for what is to be created. 

Each time CodeGen generates an output file it usually does three primary things:

1.Read information from a meta-data source, usually a repository structure.

2.Read rules from a template file.

3.Merge the rules with the meta-data to create an output file.
 

Video

Here's the Introduction to CodeGen video. Make sure you select a high-definition version of the video, by default YouTube tends to play the lowest resolution which can look pretty awful!

 

 

 


Copyright © 2012  Synergex International, Inc.