How Does Application Generation Work?
An application generator combines script templates with metadata to generate code which is then saved as files that can be run (or compiled and then run) just like any hand coded scripts. That’s it.
Imagine that you wanted to create a set of scripts to handle a simple select from a database table (OO programmers should be thinking DAO generation, functional fusebox programmers might be considering generating their qry_ scripts). Somewhere you’d have a script template that included place holders for the field name list, table name, where clause and order by clause and somewhere else you’d have metadata containing the appropriate values. For each you would also have to know the directory and file name to save the generated file to, and then you’d just need to call an application generator like CF Template.
A naïve partial script template for generating ColdFusion select queries using CF template:
SELECT ##FieldNameList##
FROM ##TableName##
##WhereClause##
##OrderByClause##
</cfquery>
CF Template is a simple open source generator that makes it extremely easy for ColdFusion developers to leverage the power of the ColdFusion language to generate scripts. Other common templating approaches are XSLT and the Velocity templating language which is part of the Java Struts framework.
Application generation is language agnostic – you can use it to generate ColdFusion, Java, .NET, PHP, Python, Ruby, SQL or any other scripting or programming language. Also, the templating language you use is independent of the programming language you generate. I like to use CF Template to generate .cs code behind pages for .NET. Why? Because I like ColdFusion and it just kind of feels a little subversive (sad, I know, but I don’t get out much :->).
You can also use the same techniques to create unit tests, Ant build scripts, XML files, documentation or even proposals – possibly all from the same metabase. A purist might argue that if the script you generate isn’t either executable or can’t be compiled to executable code it is not application generation. In practice though, I’ll cover generating all of the artifacts that help you to get a project out the door and money in your pocket quicker and with less repetition and drudgery.





There are no comments for this entry.
[Add Comment]