Mixed Code Generation

According to JackHerrington? in the book CodeGenerationInAction?, Mixed Code Generation is described as a type of ActiveCodeGeneration in which the generator "reads a source code file and then modifies and replaces the file in place."

For this to work, each generation target must be identified with a tag stored within a comment in the source code, and after generation, each generated section is wrapped in begin/end tags also in comments. Since each target block can now be precisely identified, the code generator can be run again with updated definitions on the same file to properly update all affected targets.

As an example, the as yet unnamed tool being developed by the VbeXtremeTeam uses an XML-based syntax for tags stored in VisualBasic comments, something like this...

Original code:

 '/<'MacroDef name="macro1">
 '/    Debug.Print "Test1"
 '/    Debug.Print "Test2"
 '/</'MacroDef>

Public Sub Foo() '/<Macro name="macro1"/> End Sub

Code after running the generator:

 '/<MacroDef name="macro1">
 '/    Debug.Print "Test1"
 '/    Debug.Print "Test2"
 '/</MacroDef>

Public Sub Foo() '/<Macro name="macro1"> Debug.Print "Test1" Debug.Print "Test2" '/</Macro> End Sub
-- SteveJorgensen


XmlForOnceAndOnlyOnce


EditText of this page (last edited June 17, 2005) or FindPage with title or text search