REST

So over my bank holiday weekend, I managed to set aside some time and read through the book RESTful Web Services published by O’Reilly. It’s amazing to see how things in the internet world are going back to basics, using the HTTP protocol and the web exactly how it was intended to be used.

REST, as first found in Roy Fieldings dissertation (found here), describes the concept of how correctly the HTTP verbs, GET, PUT, POST and DELETE, should be used when exchanging information over HTTP. The concept includes how the URI should only ever be used to address resources in a given service, where resources encapsulate the state held within the service. By using the 4 HTTP verbs, we can retrieve different kinds of representations such as XHTML, JSON etc. of a services resources and change its state.

REST is the transition of bringing web programming models back to the uniform interface of HTTP, and leveraging all the things HTTP has to offer that have been missed when using traditional RPC style service design. REST also states that a request from a client contains all the information inside of it, for the service to fulfill the request, without any assumed previous conversation with the client. This simply meaning, the server does not hold session like state of the interaction between it and the client. This concept can take a little while to wrap your head around, but when you get in the way of thinking that everything in REST is orientated around resources and its state, you begin to see immediately how everything you did previously can be achieved using the 4 HTTP verbs GET, PUT, POST and DELETE.

One of the biggest advantages of REST is allowing horizontal scalability due its stateless conversational design. Session affinity and replication also do not apply here unless you create that concept yourself. REST also gives interoperability due to its conformation to uniform HTTP and is considered a key step in Service Orientated Architecture.

It came to light how distant web services and web programming are from how the internet was originally intended to be used. We’ve abused the HTTP verbs such as GET, making it unsafe. By unsafe, I mean how a GET request can change the state of a service when all it was ever intended to do was retrieve information.

One of the biggest influences I’ve seen from REST is in ASP .NET MVC. Things like the view state and post backs have been removed, and design has taken on the Model View Controller design pattern where controllers represent the resources. The same design can also be seen in Ruby on Rails. I believe ASP .NET developers have quite a transition to make with ASP .NET MVC after these highly dependent concepts of view state and post back are taken away, and you are left with understanding how those concepts can be achieved through RESTful design.

Some examples of REST are Amazon S3 and Yahoo’s Flickr service.

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s