Practical Code Generation

I’ve worked with scaffolders such as Model Glue and Fusebox 5.5 with mixed results and opinions. Primarily scaffolding for me has been used to create a quick prototype. It’s great for routine tasks like creating a DAO with just a bit of information about the DB. However, as Peter pointed out, most of the generated code is highly modified and most likely tossed by the time we deploy. Additionally each change requires changes to the generated code. I really liked Peter’s concept that code should be able to be generated easily as the application changes.

After going through a bit of theory on code generation, Peter walked through his CF Template application which is an open source code generation CFC which uses metadata and templates to generate all the code. What’s really cool about it is that it uses ColdFusion to generate ColdFusion. Even cooler is that in theory, it could be used to generate code in nearly any language if that’s what floats your boat.

I walked away with some good ideas about how to try to use code generation and CF Template in my daily work. We use Fusebox 4.1 in our daily work, with much of our older code not in CFCs. I’m thinking that some of the older apps I work on written strictly using Fusebox should have files simple enough to use as a starting point to experimenting with code generation using CF Template. I did a little surfing to find tutorials and documentation and came upon Brian Caufield’s wiki where he has created templates for generating many routine files we might use regularly. He even provides a demo based on the CFArtGallery database which comes with ColdFusion. I’m really looking forward to trying to make practical use of CF Template.

Automating the Deployment/Build Process with ANT

I was eager to attend this session even though it was the last session of a long day. At work, I’ve been playing with ANT to do simple copy tasks, but have been reading about the myriad of tasks available. Since we work in Fusebox 4.1, each new application requires a copy of the core Fusebox files. I have been able to create a basic ANT script which copies the files to the set directory for use in a new project. Ultimately, I would like to use ANT to do daily checkouts via ftp at the start of the day from the development server and a checkin at the end of the day back to the development server.

Marc must have known I was coming because he essentially covered all the stuff on my wishlist. It actually looks pretty simple to automate a lot of the routine tasks using ANT. You can bet I’ll be working to integrate this into my daily work in the very near future.

The day would have been perfect with lots of new information and tips that could prove useful in my daily work. However, at the end of the day, I had to put out a fire at work which was made that much worse by the fact that all the developers are attending CFUnited this week. Oops.