RESTful Organizing Systems

Principles and Patterns of Organizing Systems [./]
Spring 2011 — INFO 290-6 (CCN 42628)

Erik Wilde and Robert J. Glushko, UC Berkeley School of Information
2011-03-01

Creative Commons License [http://creativecommons.org/licenses/by/3.0/]

This work is licensed under a CC
Attribution 3.0 Unported License
[http://creativecommons.org/licenses/by/3.0/]

Contents E. Wilde: RESTful Organizing Systems

Contents

E. Wilde: RESTful Organizing Systems

(2) Abstract

Representational State Transfer (REST) is an architectural style for building distributed systems. The Web is an example for such a system. REST-style applications can be built using a wide variety of technologies. REST's main principles are those of resource-oriented states and functionalities, the idea of a unique way of identifying resources, and the idea of how operations on these resources are defined in terms of a single protocol for interacting with resources. REST-oriented system design leads to systems which are open, scalable, extensible, and easy to understand.



Abstraction Layers

Outline (Abstraction Layers)

  1. Abstraction Layers [3]
  2. REST: The Definition [6]
  3. Web Architecture [6]
    1. Uniform Resource Identifier (URI) [2]
    2. Hypertext Transfer Protocol (HTTP) [3]
Abstraction Layers E. Wilde: RESTful Organizing Systems

(4) What is REST?

  1. An architectural style for building loosely coupled systems
    • defined by a set of general constraints (principles)
    • the Web (URI/HTTP/HTML/XML) is an instance of this style
  2. The Web used correctly (i.e., not using the Web as transport)
    • HTTP is built according to RESTful principles
    • services are built on top of Web standards without misusing them
    • most importantly, HTTP is an application protocol (not a transport protocol)
  3. Anything that uses HTTP and XML (XML without SOAP)
    • XML-RPC was the first approach for this
    • violates REST because there is no uniform interface


Abstraction Layers E. Wilde: RESTful Organizing Systems

(5) Architectural Styles

Louvre Interior
  • Architecture: Louvre [http://en.wikipedia.org/wiki/Louvre]
  • Architectural Style: Baroque [http://en.wikipedia.org/wiki/Baroque_architecture]
Villa Savoye Interior
  • Architecture: Villa Savoye [http://en.wikipedia.org/wiki/Villa_Savoye]
  • Architectural Style: International Style [http://en.wikipedia.org/wiki/International_Style_(architecture)]


Abstraction Layers E. Wilde: RESTful Organizing Systems

(6) REST is not an Architecture



REST: The Definition

Outline (REST: The Definition)

  1. Abstraction Layers [3]
  2. REST: The Definition [6]
  3. Web Architecture [6]
    1. Uniform Resource Identifier (URI) [2]
    2. Hypertext Transfer Protocol (HTTP) [3]
REST: The Definition E. Wilde: RESTful Organizing Systems

(8) The REST Architectural Style

  1. Resource Identification [Resource Identification (1)]
  2. Uniform Interface [Uniform Interface (1)]
  3. Self-Describing Messages [Self-Describing Messages (1)]
  4. Hypermedia Driving Application State [Hypermedia Driving Application State (1)]
  5. Stateless Interactions [Stateless Interactions (1)]


REST: The Definition E. Wilde: RESTful Organizing Systems

(9) Resource Identification



REST: The Definition E. Wilde: RESTful Organizing Systems

(10) Uniform Interface



REST: The Definition E. Wilde: RESTful Organizing Systems

(11) Self-Describing Messages



REST: The Definition E. Wilde: RESTful Organizing Systems

(12) Hypermedia Driving Application State



REST: The Definition E. Wilde: RESTful Organizing Systems

(13) Stateless Interactions



Web Architecture

Outline (Web Architecture)

  1. Abstraction Layers [3]
  2. REST: The Definition [6]
  3. Web Architecture [6]
    1. Uniform Resource Identifier (URI) [2]
    2. Hypertext Transfer Protocol (HTTP) [3]
Web Architecture E. Wilde: RESTful Organizing Systems

(15) What is the Web?



Uniform Resource Identifier (URI)

Outline (Uniform Resource Identifier (URI))

  1. Abstraction Layers [3]
  2. REST: The Definition [6]
  3. Web Architecture [6]
    1. Uniform Resource Identifier (URI) [2]
    2. Hypertext Transfer Protocol (HTTP) [3]
Uniform Resource Identifier (URI) E. Wilde: RESTful Organizing Systems

(17) Identifying Resources on the Web

  • Essential for implementing a Resource Identification [Resource Identification (1)]
  • URIs [http://dret.net/lectures/web-fall10/uri] are human-readable universal identifiers for stuff
    • many identification schemes are not human-readable (binary or hex strings)
    • many RPC-based systems do not have universally identified objects
  • Making every thing a universally unique identified thing is important
    • it removes the necessity to scope non-universal identifiers
    • it allows to talk about all things in exactly the same way
  • URI-identified things should have well-defined interactions


Uniform Resource Identifier (URI) E. Wilde: RESTful Organizing Systems

(18) Processing URIs

  • Processing URIs is not as trivial as it may seem
    • escaping and normalization rules are non-trivial
    • many implementations are broken
    • complain about broken implementations
    • even more complicated when processing an Internationalized Resource Identifier (IRI)
  • URIs are not just strings
    • URIs are strings with a considerable set of rules attached to them
    • implementing all these rules is non-trivial
    • implementing all these rules is crucial
    • application development environments provide functions for URI handling


Hypertext Transfer Protocol (HTTP)

Outline (Hypertext Transfer Protocol (HTTP))

  1. Abstraction Layers [3]
  2. REST: The Definition [6]
  3. Web Architecture [6]
    1. Uniform Resource Identifier (URI) [2]
    2. Hypertext Transfer Protocol (HTTP) [3]
Hypertext Transfer Protocol (HTTP) E. Wilde: RESTful Organizing Systems

(20) RESTful Applications Talk HTTP

  • HTTP [http://dret.net/lectures/web-fall10/http] is essential for implementing a Uniform Interface [Uniform Interface (1)]
    • HTTP defines a small set of methods for acting on URI-identified resources
  • Misusing HTTP turns application into non-RESTful applications
    • they lose the capability to be used just by adhering to REST principles
    • it's a bad sign when you think you need an interface description language
  • Extending HTTP turns applications into more specialized RESTful applications
    • may be appropriate when more operations are required
    • seriously reduces the number of potential clients


Hypertext Transfer Protocol (HTTP) E. Wilde: RESTful Organizing Systems

(21) HTTP Methods

  • Safe methods can be ignored or repeated without side-effects
    • arithmetically safe: 41 × 1 × 1 × 1 × 1 …
    • in practice, without side-effects means without relevant side-effects
  • Idempotent methods can be repeated without side-effects
    • arithmetically idempotent: 41 × 0 × 0 × 0 × 0 …
    • in practice, without side-effects means without relevant side-effects
  • Unsafe and non-idempotent methods should be treated with care
  • HTTP has two main safe methods: GET HEAD
  • HTTP has two main idempotent methods: PUT DELETE
  • HTTP has one main overload method: POST


Hypertext Transfer Protocol (HTTP) E. Wilde: RESTful Organizing Systems

(22) Cookies

  • Cookies [http://dret.net/lectures/web-fall10/webstorage#cookies] are client site state bound to a domain
    • they are convenient because they work without having to use a representation
    • they are inconvenient because they are not embedded in representations
  • Cookies are managed by the client
    • they are shared across browser tabs
    • they are not shared across browsers used by the same user
    • essentially, the client model of cookies is a bit outdated
  • Two major things to look out for when using cookies:
    1. session IDs are application state (i.e., non-resource state)
    2. cookies break the back button (requests contain a URI/cookie combo)
  • The ideal RESTful cookie is never sent to the server
    • cookies as persistent data storage on the client
    • interactions with the server are only using URIs and representations


E. Wilde: RESTful Organizing Systems

(23) Conclusions



2011-03-01 Principles and Patterns of Organizing Systems [./]
Spring 2011 — INFO 290-6 (CCN 42628)