Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

The various talks I have watched and tutorials I scanned on REST seem to stress something called 'discoverability'. To my limited understanding, the term seems to mean that a client should be able to go to http://URL - and automatically get a list of things it can do.

What I am having trouble understanding - is that 'software clients' are not human beings. They are just programs that do not have the intuitive knowledge to understand what exactly to do with the links provided. Only people can go to a website and make sense of the text and links presented and act on it.

So what is the point of discoverability, when the client code that accesses such discoverable URLs cannot actually do anything with it, unless the human developer of the client actually experiments with the resources presented? This looks like the exact same thing as defining the set of available functions in a Documentation manual, just from a different direction and actually involving more work for the developer. Why is this second approach of pre-defining what can be done in a document external to the actual REST resources, considered inferior?

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

The need for discoverability may not be relevant, but the links that allow discoverability serve more purposes. The most important of these, to my mind, is that providing full URI's in the responses to the client, means that no client will ever need to "compose" an URI. That means that no client will ever need knowledge about how the URI's are structured. And that in turn allows the server developers to change the URI scheme whenever it suits them as they do not need to consider older clients still relying on an old way of structuring URI's.

share|improve this answer
    
Yes, I think I can make sense of that... but can you also please point me to a link with a concrete code example? A 'versus' change between how a resource embedded with discoverable URLs provide a better insurance for the future? –  aditya menon Oct 20 '12 at 14:26
    
Sorry, no links. Just common sense and years of having to maintain code in server apps to keep it backwards compatible with older clients. Whenever you have a client/server type situation, you need servers backwards compatible with old clients as you can NOT change an old client once it has been deployed. This holds even if you control both web client and server code and always deliver them as a whole: you can do without the headaches during development so a web client team can develop as independently as possible from the back end team. –  Marjan Venema Oct 20 '12 at 17:11
add comment

"Clients" may not be advanced enough to make use of it, but the users of clients can. A client can be something as simple as a web browser, after all. The discoverability is all about enabling people to learn and use the API.

For example, Jenkins (the CI server) has a REST-like interface. Go to any page, postfix the URL with "/api", and you get a page describing everything you can do. It makes learning the API trivial. For example, http://ci.jruby.org takes you to the jenkins server for jruby, and http://ci.jruby.org/api takes you to the api for that specific page.

share|improve this answer
add comment

NOTE: I'm no expert on the subject, but I went thru a similar process of trying to reconcile the different nuances of peoples interpretation of "REST" a few years ago, and this is the takeaway I got from looking into it at the time.

To my understanding, this stems from Roy Fielding's Hypermedia as the Engine of Application State aka "HATEOAS", which then becomes an enabler of the idea of a "semantic web".

http://en.wikipedia.org/wiki/HATEOAS

So...basically, and again as I understand it, you make your RESTful application basically self describing such that the consumer does not have to have prior knowledge of a formal contract to consume your content / functionality. They are able to engage from some defaulted root endpoint and then walk contextually relevant links that your app provides as the consumer interacts. The consumer, of course, can be a person or a systemic agent.

If you are just using "REST" for pretty urls mapped to CRUD operations that a consumer must have prior knowledge of and calls according to a well known contract, Roy Fielding would deem it not truly RESTful.

That's not to say that a REST flavored RPC service set up can't be useful / an improvement over a more elaborate RPC model and suitable for limited / controlled usage, but the hardliners will look down their noses at it and consider it to be degenerate / not really REST.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.