Lecture Date: Monday, February 26
Today we're going to start discussing REST - Representation State Transfer - a software architectural style for distributed hypermedia systems, such as the web.
The main principles of REST are the following:
- Stateless Client/Server Protocol: Each message contains all the information needed by a receiver to understand and/or process it. This constraint attempts to "keep things simple" and avoid needless complexity.
- Idempotency: you get the same result from the same action
- A set of uniquely addressable resources enabled by a universal syntax for resource identification; "Everything is a Resource" in a RESTful system
- A set of well-defined operations that can be applied to all resources; In the context of HTTP, the primary methods are POST, GET, PUT, and DELETE, similar (but not exactly) to the database world's notion of CRUD (Create, Read, Update, Delete).
- The use of hypermedia both for application information and state transitions. Resources are typically stored in a structured data format that supports hypermedia links, such as HTML or XML
Let's look at how SIS works - it's command based. You do a command and the system responds. The system is built around verbs. In a RESTful system, the design emphasis is around nouns and resources - what their representation is and how they are affected by the standard methods. In REST, we assume four basic operations - Retrieve, Remove, Create, Update. Very much like Get, Delete, Post, and Put from HTTP and Select, Insert, Update, Delete from SQL.
For example, you could create an XML or JSON representation of an object that is then retrieved and modified by clients via the standard methods. Using HTTP commands, the XML or JSON could be retrieved with GET, modified, PUT back on the server.
A web application that is RESTful:
- Is bookmarkable (in general)
- Has "good looking" URLs
- Has a good data model behind it
- Often has a good external API
- Fully takes advantage of the Internet's asynchronous nature
We will first look at more examples on RESTful websites that you have found. Check out the Postman tool for connecting to RESTful APIs.
Imagine a software system made up only of various web applications, linked together through various RESTful calls. Crazy, you say?! Of course not! That's a service-oriented architecture!
UVA does this! Check out http://devhub.virginia.edu/.