


Base Input Forms and Tokens

There were a number of pieces of information that the system needed in order to do code generation. The following are the key items:
The .IN File: The base input form that was used by the system was known as a ".IN" file (after the file name suffix). A .IN is a text file that defines a className and lists attributes (both persistent and derived) and methods (with their signatures and return values) for the class. In addition, each attribute or method could have keyword/value pairs associated with it. The keywords indicate which template should be used for generation, whether a rules trigger point should be placed in the method, the documentation comments to be included, etc.
Templates: The templates define what code is to actually be generated. They are a combination of code output lines and parseable REXX code. The code output lines contain substitution parameters (ex. the factory to be called, the type to cast to, etc.) The REXX code can be sent to a REXX interpreter and allowed for conditional generation (If/Then/Else), repetitive generation (for loops), etc. Templates could call other templates and pass parameters. Templates were named after the patterns they represent.
Custom Code Points: Occasionally, a pattern could not be expressed completely as a parameterized template. A small number of hand coded lines might be needed. Locations where manual coding might be required are called "custom code points". During the first generation of a file, the code was output with markers showing where custom code could be inserted if needed. On subsequent generations, the code between the custom code point markers is protected and the rest of the code is replaced.
Generation of the .IN file From Rose: Our design was done using the Rational Rose product. To add methods or change method interaction, we would start there. On the other hand, if a developer identified a change, he would update the .IN file and regenerate. There was a fear that over time, the code would get out of sync with the design. To address this concern, we defined locations for metadata in Rose (that contained the keyword/value data) and built a generator that would generate .IN files from the Rose repository. The bridge is fully automated from Rose to .IN and partially automated from .IN to Rose.


