Wednesday, June 10, 2015

MVC & REST API

MVC was first introduced byTrygve Reenskaug, a Smalltalk developer at the Xerox Palo Alto Research Center in 1979, and helps to decouple data access and business logic from the manner in which it is displayed to the user.

A key difference between a traditional MVC controller and the RESTful web service controller above is the way that the HTTP response body is created. Rather than relying on a view technology to perform server-side rendering of the greeting data to HTML, this RESTful web service controller simply populates and returns a Greeting object. The object data will be written directly to the HTTP response as JSON.

REST is just a set of conventions about how to use HTTP. A "REST API" combines two things: web service and it's RESTful feature. By virtue of being a web service, you get some loose coupling.  The client need not be aware of internal implementation details and there is, as you note, a real opportunity for platform/language independence.

Being RESTful offers additional benefits aimed at additional decoupling, so as to allow extreme scalability. REST forbids conversational state, which means we can scale very wide by adding additional server nodes behind a load balancer.

No comments: