Saturday, October 28, 2006

path and args

There is a drive to convert all the addresses with GET parameters to paths.
http://www.domain.com/book?author=Dostoyevsky
becomes
http://www.domain.com/book/Dostoyevsky.
But what if we add a genre to that search?
http://www.domain.com/book/Dostoyevsky/memoir
or
http://www.domain.com/book/memoir/Dostoyevsky
?
We need to arbitrary decide about the position of the arguments. But what if both of the arguments are optional? Then we need to reserve some string to play the role of 'undef'. We need to add two unnecessary, arbitrary conventions - complicating the code and also the usage.

Perhaps we should rather do
http://www.domain.com/book/author/Dostoyevsky/genre/memoir
with the semantic that everything after /book/ is actually the same old key=value pair and that the order of the pairs has no meaning. Does this really buy us something? I don't know - I would rather see:
http://www.domain.com/book?author=Dostoyevsky;genre=memoir and know from the start how to manipulate it, and that I don't need to care about the order of the pairs.

Why on Earth change all named parameters to positional ones?

For Plugger: Catalyst.