W3C home > Mailing lists > Public > uri@w3.org > October 2007

Re: URI Templates - optional variables?

From: Roy T. Fielding <fielding@gbiv.com>
Date: Tue, 16 Oct 2007 16:48:06 -0700
Message-Id: <1E7DE1DC-B045-486E-BB09-2F3BD0C694A8@gbiv.com>
Cc: "Mark Nottingham" <mnot@mnot.net>, "Stefan Eissing" <stefan.eissing@greenbytes.de>, URI <uri@w3.org>, "Joe Gregorio" <joe@bitworking.org>
To: DeWitt Clinton <dewitt@unto.net>

On Oct 16, 2007, at 3:11 PM, DeWitt Clinton wrote:

> To jump in for a second (agreeing with at least half the people on  
> this thread):
>
> One of the big wins I think we got with the OpenSearch URL  
> templates was their readability, and write-ability, for humans  
> without tools.
>
> Consider this:
>
>   http://example.com/search?q={searchTerms}&num={count}
>
> Quick -- tell me what that template describes.  I bet you can.  And  
> I bet you could create one by hand.
>
> Granted Joe's proposed URL template specification is far more  
> general in its expressiveness.  But it is also already starting to  
> feel overly complex.  If it gets even more complex I'm afraid we'll  
> have lost most of the audience of real people who build the bulk of  
> the world's web applications.

I don't get it.  Here is your template

    http://example.com/search?q={searchTerms}&num={count}

and here is the same template in Joe's syntax

    http://example.com/search?q={searchTerms}&num={count}

Note that they are identical.  Most likely, however, the template is
wrong because the service also accepts

    http://example.com/search?q={searchTerms}
    http://example.com/search?num={count}
    http://example.com/search?

so the only template that is really going to describe your
service is (in Joe's syntax)

    http://example.com/search?{,&|q,num}

which is only less readable because the choice of parameter
names isn't readable.  If it instead said

    http://example.com/search?{,&|query,max_results}

then I argue that is, in fact, both more readable and more
accurate than the original template you gave above, in addition
to being shorter.  YMMV.

In any case, you can continue using your simpler template even
if the standard allows more complex forms to those who want them.

....Roy
Received on Tuesday, 16 October 2007 23:48:19 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 13 January 2011 12:15:37 GMT