Ionrock Dot Org

by Eric Larson

My Weblog

URLs Rule the World

So, Bill de hÓra has been blogging quite a bit on URLs and their design. What is interesting to me is that context of today’s entry, he reveals JSPs don’t have something like Routes. This is something of interest to me simply because I have written and used quite a few dispatchers over the past few months with the common theme being it is a simple problem to solve.

You can easily dispatch on the typical:

/{controller}/{method}/{*args}

without much trouble. In Bright Content, we use regex to get dates and create essentially an ID. I have also done slightly more complex patterns such as

/{model}/{id}/{action}/{args}

What is interesting is this method of viewing URLs is really different from something like mod_rewrite because there is an assumption made that the URL contains important keys to the resource. I am not sure if this is conventional wisdom regarding cool URIs, but it seems like it should be. From the Java/C# perspective, I can see why someone could essentially disregard the content of the URL in favor of GET parameters. The history behind the tools and frameworks have been to use GET parameters instead of utilizing the URL tokens, which makes sense because there is less ambiguity. For example, if I have a url:

/blog/2007/3/14/Some_Slugged_Up_Title/

The question arises as to what each token (that which is split by the “/” character) represents. In the above example, the pattern is essentially

/{controller}/{year}/{month}/{day}/{slug}

But the issue is that the year, month and day could be considered one parameter. The slug then could also be different based on an extension, meaning that in the case above, I have a trailing slash, yet if I added a “.atom”, it might serve a different content type.

These really aren’t hard problems to deal with, but I can imagine that for some, it is a new way of thinking. I know as I have thought about the problem the issues run very deep and there is little to stop you from making bad decisions that can really hurt an application’s design. It is always interesting to see issues that seem simple become complicated by going one path and then finding a new direction that starts the process all over again.

Posted Thu Aug 16 16:47:50 2007 by Eric Larson
using python, jquery and emacs ;)