By Peter Bell

Dynamic Programming vs. Application Generation

As you might guess from the title of this blog, I’m a long time proponent of application generation – as I said on my cf.objective() bio, I’m just too lazy to write code when a computer could do it for me!

I’ve been having a bunch of fun over the last six months rewriting a CF5 application generator to take full advantage of Object Oriented design patterns and best practices. One of the things I am now playing with is how best to balance application generation with dynamic programming.

What’s the Difference?
The main difference between dynamic programming and application generation is how your metadata is used to affect your program execution (not when as some people think). Typically with application generation, metadata is combined with a template (string concatenation can also be used) to generate a script, which is then saved to the server hard drive ready for execution. This might happen in advance as some kind of generation or publishing step or it could happen as part of program execution (think: Reator). The key is that the program just generates a file to be executed that could theoretically have been coded by hand. With dynamic programming, the metadata is consumed and directs the program flow at runtime and no additional scripts or files are generated at all.

All other things being equal, application generation delivers better performing and simpler applications (because the complexity of the variability is abstracted out of the actual program into the generator), but dynamic programming can be more readable for developers without an application generation background and it is sometimes easier to prototype a dynamic application than to create all of the infrastructure required to implement a sophisticated application generator with a reusable metabase. Application generation solutions can also be more complex if you factor in the complexity of the generator and it’s associated infrastructure.

An Approach
I am finding that while my metadata schemas and domain specific languages are still quite fluid (I still have to keep refining the properties I use to describe things quite often), I am using dynamic programming wherever possible as it is much quicker to change a couple of parameters in an object and perhaps the interface to a method than to have to change the structure of the metabase and the associated code for retrieving that as well as the template for putting that into, so for now my approach will be to make pretty much everything use dynamic techniques and then to refactor to generation when appropriate.

The only exceptions will be for publishers or generators that are actually easier to implement using a "publish and include" pattern to solve a specific language limitation.

Related Blog Entries

Comments
Sounds like we are working on the same sort of things here. I am also converting my CF5, FB3/4 code generator to CF7 and FB5.
# Posted By Kevin Roche | 8/15/06 12:10 PM
Hi Kevin,

Cool - we should probably trade notes! What kind of apps do you generate?

Best Wishes,
Peter
# Posted By Peter Bell | 8/15/06 12:27 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.005.