The answer seems obvious. Code Generation is Code Generating Code. Basically it is a skeleton filled in by a parser looking for variable parts. Off course in it's simplest form that's what it is.
But there is much more to it. Straight code generation does not allow you to have an extensible framework to build upon. True code generation should build on a flexible object oriented code generation framework with a hierarchical template set in which you can hook either with custom code or with other templates. Thats' just what we have been building, and it is extremely powerful. Templates can independently from each other generate code not only into each other but in different files.
Our templates are C# classes that implement certain interfaces. Each template uses a codeblock structure. All templates expose code insertion points. For instance the following code:
PageTemplate.AtPageLoadEnd.Add("{0}_ActionChanged(\"Browse\");", PrimaryControl.Name);
used in a template generates at an ASX page code behind in the AtPageLoad event, in the last code block of the Aspx Page template. These code insertion points can be used in all templates.
No comments:
Post a Comment