About CodeGen.

What it does and how it works.

CodeGen creates source code, but of course it can't just generate any old piece of source code that a developer might imagine. Yes, that would be cool ... but then we wouldn't need developers any more! Before code can be generated a developer must declare the rules that define how a specific piece of source code should be created. These rules are defined in template files. CodeGen reads one or more templates and follows the rules that the developer has defined.

Defining programming rules in template files 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. That data is ultimately stored in some type of persistent storage, perhaps in a collection of data files, or tables in a relational database. When software developers work on a particular piece of source code, they often combine 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 use the Synergy Development Environment they have access to an excellent source of meta-data called the Synergy/DE Repository. A repository can hold extensive information about an application's data structures, and the attributes of those data structures. A repository can also contain information about the relationships between the data structures, and even about underlying data storage mechanisms. A Synergy repository is a very rich source of meta-data, and is the primary source of meta-data used by CodeGen.

Some Synergy developers also use the Synergy UI Toolkit to present their application's UI, and in this case there may also be a second excellent source of meta-data in the form of Window Script files. In some situations CodeGen may be able to leverage the meta-data contained within these files also.

It’s all about meta-data! In a nutshell, CodeGen takes information about one of an application's data structures, and then combines that information with rules that have been defined in a template file in order to create some type of useful output text.

Basic Principles

Each time programmers use CodeGen to generate code, they typically provide two primary pieces of information:

  1. The name of one or more template files which define the rules for what is to be created.
  2. A source of meta-data, usually the name of a repository structure.

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

  1. Read rules from a template file.
  2. Read information from a meta-data source, usually a repository structure.
  3. Merge the rules with the meta-data to create an output file.

For more information about how CodeGen works, please refer to the CodeGen documentation.