Smart Frameworks: Utalizing Rich Metadata and Code Generation, by Elliott Sprehn

Notes from Elliott Sprehns talk on Smart Frameworks at Frameworks 2007. After 6 posts today I was starting to get a little spacey by the time this one came around. It was a great presentation though, and offered a lot of comparisons of coldfusion frameworks to Rails and what we can learn from them to make our lives easier, as well as how additional metadata in functions or arguments can help fill in the gaps in our metadata.

With the Scaffolding BOF session either canceled or just empty (it is the end of the day on the last day after all), I headed to the Smart Frameworks presentation instead.

One of the benefits of a framework is the ability to not repeat yourself. By centralizing your application logic in xml files you create a description of your application. This can be ported over to another language (besides coldfusion) because this is merely declaration of the application.

We duplicate code all the time in frameworks. For instance in Transfer you create a column in a database, then add a property tag in the Transfer XML. Like wise in ModelGlue you declare the message listener and the function name in the controller. Although this decouples the message from the controller and the function, it might be overkill and duplicate information if you’re not utalizing the message listeners to multiple function calls.

Conventions come in handy! For instance in rails you have underscores in database column names, such as first_name. When this is translated to code, it would come out with a getFirstName function based on just that column name, and return the same thing everytime. Likewise in Model-Glue, you might have a needFirstName message that calls a getFirstName method.

Metadata can be intrusive or non-intrusive. Non-intrusive metadata is stuff you don’t have to think about. Intrusive metatdata on the other hand is awkward and not a standard. Configuration in this method is intrusive.

It looks like a lot of the topics he’s talking about — search engine safe URLs that can be expanded on, no xml files, automatic mapping for requests and that kind of thing. It looks like a lot of the concepts he’s mentioning are available in Coldfusion On Wheels.

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments
“By centralizing your application logic in xml files you create a description of your application. This can be ported over to another language (besides coldfusion) because this is merely declaration of the application.”

You know, I never thought about it that way. That is a pretty cool aspect of using XML to configure your application. I thought some more about it though, and realized “you know, you’d more than likely have to write the framework in the other language.” But, it is still a cool possibility!

I’d guess the biggest advantage is for a frameworks that already are in multiple languages, like fusebox which has a PHP, or even Coldspring where things could be converted to Java Spring. Either way though the advantage of having your application described is there for porting. In the end though, I rarely see anything like this being used, but having a description of how things are put together is helpful assuming it doesn’t take up too much time i suppose.
I’m really glad you got a lot out of the presentation!

In response to the portability aspect of XML, a big advantage of using conventions is that you can generate that high level view by inspecting your code. Admittedly this is quite a bit more work for the framework developers, but its certainly possible to extract the metadata from cfcs and generate XML.

As for frameworks: CFWheels is one project, there’s also cfrails: http://cfrails.riaforge.org/

Sean has also been taking feedback on how to enhance Fusebox 5 to utilize the great inspection features in CF as well as implement smart defaults for certain actions (ex. Login).

I think we’re going to see great things out of the Model-Glue and Fusebox communities in the coming year.

Man, seeing some of the topics discussed implemented in Fusebox of ModelGlue would be really great for the entire cf community. As for CFRails I’m going to have to give it a shot one of these days. Sammy is a smart guy so I’m sure the framework is coming along nicely.

Did you happen to go to Chris Scott’s talk on AOP? I think it was in there that he talked a lot about metadata in CFCs. I think he said he was releasing a security pack utalizing metadata for role based access in one of the later versions of Coldspring (so that it can be free licensing wise).

Leave a comment

(required)

(required)