A RESTFul Pager
I learn something new nearly every time I write code - whether in a small project or large.
I recently updated my online gallery component at http://www.58bits.com/otherblog/photos/home.aspx . One of my TODO: items was a rewrite of a VCR style pager I've used previously. What I wanted was a style like the one shown in the screen shot...
similar to that used on many sites. I also wanted user friendly(ish), hackable URLs, with each URL truly representing a resource; resources that may have more than one representation. For example, what you see visually as a user visiting the site - is a page with either thumbnails or a preview on it. However if you're an RSS reader, or a slide-show plug-in, you'll be given an RSS/XML representation of the same resource.
So what did I inadvertently create by moving to the new pager style? A RESTFul pager. By asking for pages using the HTTP GET verb (as opposed to my old VCR pager that relied on forms and POST - ok a bad move I know) - I now have URLs that look like this...
http://www.58bits.com/otherblog/photos/5cgg96ab3e6g/thumbnails/2/2x3/view.aspx
And I now have a good separation from the server implementation, and the client's perception of a resource via a cool URL, and one that won't change .
As an aside, I can also now do something intelligent with caching, telling the client whether the resource has been updated or not via ETags, last modified dates and HTTP 304 response codes, saving a ton of bandwidth while at the same time ensure that changes propagate.
I'm a newbie to REST as an architectural style and am currently reading a lot on the topic - but what I've found from my initial exploration is that if you've been programming the Web for a little while, you've been close to REST by default. Embracing the style to include other verbs (other than the ubiquitous GET) is not such a big step, and I'm looking forward to experimenting further.
Here's a link to an author that's produced a great presentation on RESTFul Web Services