I wrote a bit ago about using Brian Rinaldi's Illudium PU-36 Code Generator for a project at work. There was actually a pretty good response to the post. And people seemed interested in how I was using Illudium (outside of it's Flex front-end). So, this will be the first post in a series about building a database abstraction system.
So, what was the impetus for all of this? I work on a massive Fusebox 3 application. A large portion of it was written before CFMX. So, most of our database access is in qry_xxx.cfm files. This is OK. At least it's fairly organized. The first time this was really not OK was when we started experimenting with Flex and remoting. For remoting, you really need to use CFCs. But, we really didn't want to just cut and paste the same query into a CFC and have to maintain it in two places. And we really didn't have the time or man-power to rewrite all our data access. So, we basically gave up the idea.
Then our application got bigger and bigger. We hired more people. And there was more not-OK-ness. Like, I'm sick of writing the same boiler plate SQL for every new table I make. And it's actually sort of a pain for multiple developers to go see if somewhere in our massive application the query that they want is already written. So, for some time now, I have been really wanting to find a solution to standardize our database access.
I tried at one point using Doug Hughes' Reactor framework. But, there were some issues with getting it to pick up schema changes on a live server under load. Also, my boss wasn't really a fan of it's black-box-ness. Transfer is cool too. But, it has that same black-box-ness.
So, for requirements at work, what I really needed was:
- Something to generate CFCs that would handle our database access.
- For the CFCs to be easily found and read once generated.
- For there to be a way for us to customize the functionality of the objects.
At some point I found the Illudium PU-36 Code Generator. It fit the bill because it uses a templating system. So, you can customize the code that it generates. In my next post I'll go over using Illudium outside of it's Flex front-end.