Front Controller Frameworks Suck
posted under category: ColdFusion on March 2, 2010 by Nathan
I always hated them for this one reason. How do you explain this URL:www.example.com/index.cfm?fuseaction=main.default
What I dislike about that is...
- It's hard for your users to remember or even type
- It's ugly to see
- Your web stats say everyone visited one page - index.cfm - they had different query strings, but they only visited one page
- Your SEO is hurt. How does the googlebot know the difference in importance between the fuseaction query param over any other params? Sure, it's smart, it knows, but it can't really know, you know?
- It reduces the number of results in this search
Really, it comes down to your users, their experience, and how they see your application. While it's not as important as your usability, design, content or uptime, it does take away from the overall quality.
So what can be done about this problem? Few have tried, some have succeeded. Here are the strategies that are out there.
- CFM pages everywhere.
This is generally the opposite of using a framework. All of the hassle, none of the benefit. - URL Rewriting. As requests come to the server with an attractive URI, they are translated into whatever your application needs to load it by.
This is a good strategy, and it works well. On Windows with IIS, most of the software is either expensive or buggy, and definitely not portable. On Apache, mod_rewrite is great. Either way, you cannot make a cross-platform solution, meaning URL rewriting on an open source project is a no-go. - Generated CFM pages everywhere.
You have software that spits out static files from dynamic actions in your framework, that call back in to your framework. In our example, a /main/default.cfm page would be generated that may set the fuseaction querystring parameter and invokes the framework. This is a great solution, but I've never heard of anyone putting it to practice. Writing this software is deceptively complex. - The OnMissingTemplate rerouting method.
You link to pages that do not exist, then have an onMissingTemplate handler in your Application.cfc file that redirects requests to your framework with the right parameters. This new URL might look like example.com/main/default.cfm, which doesn't exist, so your onMissingTemplate method fakes like it's the ugly URL and invokes the framework.
Can anyone think of another method of doing it?
Personally, I like the OnMissingTemplate method a lot. The distinct advantage above the URL rewriting method is that this one is portable without installing other software. Of course it doesn't work everywhere, but it almost always will.
In summary, make your users happier and write your next application with a better SES strategy.