ColdFusion FW/1 MVC framework

I hacked around for a few hours last night with Sean Corfield’s FW/1. The site makes the following claim:

“Intended to require near-zero configuration, FW/1 lets you build your application without worrying about a framework getting in your way.”

This is mostly dead-on. I’m not a frameworks guy, and even I thought FW/1 was pretty simple to get up and running around with. It wasn’t perfect—but it was noticeably easier than the other CF frameworks I’ve used.

As I mentioned in my previous post, in the ColdFusion courses I teach the two final lectures are on ORM and Frameworks. Both lectures use a simple blog front-end as example code. I translated that code over to FW/1, mostly via copy-and-paste. You can download it, if you like:

Simple Blog Front-End using CF9 ORM and FW/1
Zip Archive, 12KB

There’s not much to it, really. I suspect you’d gain more from Ray’s posts on the subject.

I ran into the same problem that Ray initially had: the default method is named “default”, which is a reserved word in CFScript. This code breaks:

public function default(required struct rc) {

This means you’re limited to either CFML-based Controllers or you need to be extra careful about using defaults. I admit that the new CFScript is growing on me—especially for Controllers, Models, and Services—so this is a bit of a drawback. (Hacking your local copy of the framework to use defaultItem instead of default may not be a horrible idea, but may potentially limit the distributability of your code … if you care about such things.)

My other nitpick is that the FW/1 documentation is upside-down. The Controller examples show how to add service calls to the queue:

variables.fw.service( "myservice.myaction", "myresult" );

But it’s not until you get to the very end of that page that you find out that to get this variable you have to set it up yourself—it’s not one of the magic variables that the framework provides:

function init(fw) { variables.fw = fw; }

I spent half of my time banging my head against the wall with writeDump() statements trying to figure out what I was doing wrong … before I scrolled down to see that.

Beyond those two relatively minor nitpicks, it’s not a bad framework. All of the implicit invocation is nice, and the structure is logical and easy to work with. I love the way the Service objects are called with argumentCollection so that they don’t have to care about the framework. I’m not a huge fan of the way Views are done, though: there’s too much hand-wavey magic. Personally, I’d prefer to code Views as functions, too, if only to have nice, explicit arguments like the Services do. But I admit that might just be my OCD kicking in. The fallback for Views and Layouts is nice.

In all, FW/1 doesn’t suck. That’s high praise coming from an anti-framework guy like me.

By Rick Osborne

I am a web geek who has been doing this sort of thing entirely too long. I rant, I muse, I whine. That is, I am not at all atypical for my breed.