Just A Summary : Joined up thinking: why your resources want links http://www.bofh.org.uk/articles/2008/02/22/joined-up-thinking-why-your-resources-want-links.rss en-us 40 Piers Cawley Practices Punditry Comment on Joined up thinking: why your resources want links by Paul Mison <p>While I can see the sense in serving URLs for convenience, I can see cases where serving the chunks that build the URLs instead is more useful.</p> <p>As an example, Flickr&#8217;s <span class="caps">API</span> tends to return a photo element complete with all the resources needed to build a <span class="caps">URL</span> for an image (indeed, multiple versions of that image) <em>or</em> the page showing that image. (To be fair, they also offer a flickr.photos.getSizes call that returns all the URLs for you, but that requires an &#8220;API join&#8221;: <a href="http://blech.vox.com/library/post/the-api-join-and-avoiding-it.html.)" rel="nofollow">http://blech.vox.com/library/post/the-api-join-and-avoiding-it.html.)</a></p> <p>So, more generally, if you serve a <span class="caps">URL</span> which contains information that may be more useful on its own, aren&#8217;t you then forcing the <span class="caps">API</span> user to parse that <span class="caps">URL</span> for its useful information? Perhaps the answer is to serve both the <span class="caps">URL</span> and the constituent chunks, but I accept that increases app overhead.</p> Fri, 22 Feb 2008 06:39:52 -0600 urn:uuid:9cc0cd25-a8a2-4e37-8f6a-ceade0889839 http://www.bofh.org.uk/articles/2008/02/22/joined-up-thinking-why-your-resources-want-links#comment-1318 Comment on Joined up thinking: why your resources want links by Aristotle Pagaltzis <p>Piers:</p> <blockquote> <p>I can rant for ages about the awfulness of RoR’s routing system, but the bidirectional nature of them trumps almost all my complaints.</p> </blockquote> <p>Catalyst’s routing goes both ways too… and while my experience with it so far is limited, it does not seem at all awful to me. :-)</p> <p>(PS.: your preview is broken. I hope this comment comes out OK. Why does everyone these days go pure Ajax for their previews?)</p> <p>Paul Mison:</p> <blockquote> <p>aren’t you then forcing the <span class="caps">API</span> user to parse that <span class="caps">URL</span> for its useful information?</p> </blockquote> <p>No. No no no no no. Clients don’t parse URIs. Ever. If it’s not a <span class="caps">URI</span> you minted, you have no business peering at its pieces. It’s good for many reasons for URIs to be readable, but as far as the client is concerned, “<code>/topic/42/post/23</code>” is completely equivalent to “<code>/0913-jdq981k1j187</code>”.</p> <p>If the client needs to have some information, you give the client that information explicitly, not by implying it within the <span class="caps">URI</span>.</p> <blockquote> <p>Flickr’s <span class="caps">API</span> tends to return a photo element complete with all the resources needed to build a <span class="caps">URL</span> for an image (indeed, multiple versions of that image) <em>or</em> the page showing that image.</p> </blockquote> <p>Right; and if they also gave you a <span class="caps">URI</span> Template so you didn’t need to hardwire any knowledge of their <span class="caps">URI</span> space into your client, that would be fine. It’d be the equivalent of a form in <span class="caps">HTML</span>.</p> <p>Clients constructing URIs is perfectly RESTful as long as their a priori knowledge is limited to the algorithm for doing so and does not include specifics of the server’s <span class="caps">URI</span> space.</p> Fri, 22 Feb 2008 10:39:23 -0600 urn:uuid:14b6989e-8970-42ec-ae34-eb7d60273973 http://www.bofh.org.uk/articles/2008/02/22/joined-up-thinking-why-your-resources-want-links#comment-1319 Comment on Joined up thinking: why your resources want links by Paul Mison <p>Aristotle: thanks for the reply. I think we&#8217;re agreed that the <span class="caps">API</span> consumer parsing the <span class="caps">URI</span> is not desirable (although you seem to be a bit more hardcore about it than I do), hence my argument that if there&#8217;s information that may be useful that&#8217;s in the <span class="caps">URI</span>, it should be provided separately in the response. (Just because something&#8217;s wrong, doesn&#8217;t mean people won&#8217;t be tempted to do it, if you like.)</p> <p>On the subject of <span class="caps">URI</span> templates, they seem to be newer than Flickr&#8217;s <span class="caps">API</span>, which instead provides a human-readable guide to <a href="http://www.flickr.com/services/api/misc.urls.html" rel="nofollow">constructing URLs</a> from response information.</p> <p>(Regarding the Textile preview, it didn&#8217;t work for me on Safari for Windows but does on the Mac. Slightly odd.)</p> Sat, 23 Feb 2008 10:00:22 -0600 urn:uuid:5e9d023c-3a33-41d4-aa4a-1e8a1067d4d2 http://www.bofh.org.uk/articles/2008/02/22/joined-up-thinking-why-your-resources-want-links#comment-1325 Comment on Joined up thinking: why your resources want links by Piers Cawley <p>That&#8217;s because there was a problem with the way the javascript was served when you wrote your first post, but it got fixed in the second. Now I just need to tweak the javascript to keep the text entry box in the viewport at all times and I&#8217;ll be laughing&#8230;</p> Sat, 23 Feb 2008 11:38:14 -0600 urn:uuid:f0858a37-a093-4a99-955e-c85c3f1da8bf http://www.bofh.org.uk/articles/2008/02/22/joined-up-thinking-why-your-resources-want-links#comment-1326