What is Rest and is it Restfull?

According to “http://rest.elkstein.org/”, “REST stands for Representational State Transfer. (It is sometimes spelled “ReST”.) It relies on a stateless, client-server, cacheable communications protocol — and in virtually all cases, the HTTP protocol is used.”

Stefan Tilkov  describes REST as having the following key principles:

  • Give every “thing” an ID
  • Link things together
  • Use standard methods
  • Resources with multiple representations
  • Communicate statelessly

You can visit his page for a breakdown and description of each of the principles. http://www.infoq.com/articles/rest-introduction

Elkstein goes on to say that “RESTful applications use HTTP requests to post data (create and/or update), read data (e.g., make queries), and delete data. Thus, REST uses HTTP for all four CRUD (Create/Read/Update/Delete) operations.”

Because of the way REST is used, it is more of a way of doing things than a standard communication language. There will probably never be a MIB or W3C recommendation. REST does not provide a mechanism for unsolicited information transfer. There is no concept of publish and subscribe. In order to receive information from a resource in real time you have to use mechanisms like a lingering get. This means that you start communication with a get and when the resource has something to say it responds to the get. As soon as you get a response you send another get. It’s not quite polling, but it’s closer to that than an asynchronous communication protocol.

REST does dumb down the programming interface to a few standard methods that resemble a base class for an object oriented programming language.

class Resource {
     Resource(URI u);
     Response get();
     Response post(Request r);
     Response put(Request r);
     Response delete();
}

There is a framework for the iPhone, iPad and MacOS that you can add to you projects that abstracts the REST details. You can find it here https://github.com/RestKit/RestKit.
The instructions are a bit complex to follow but once you get the framework integrated into your IOS project, the underlying protocol disappears.

There are no shortage of sites and tutorials that try to explain and demonstrate REST as a simple communication protocol, but as I investigate the implementations it seems to be more complex that your standard plain text control interface. I had an auto mechanics teacher in high school that would thump you on the head if you tried to use a wrench as a hammer. I would suggest to you that replacing a plain text control interface with REST is like using a wrench as a hammer. In many cases the wrench will do the trick, but it’s just not the right tool.

This entry was posted in General and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *