More REST less ROT (2011-06)
Upcoming SlideShare
Loading in...5

More REST less ROT (2011-06)






Total Views
Views on SlideShare
Embed Views



0 Embeds 0

No embeds



Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

More REST less ROT (2011-06) More REST less ROT (2011-06) Presentation Transcript

  • Mike Amundsen @mamund
  • “You cant cross the sea merely by standing and staring atthe water.”- Rabindranath Tagore
  • Mike Amundsen Presenter, Architect, Programmer Current focus: “Hypermedia” New book coming… Designing Hypermedia APIs w/ HTML5 and NodeJS – O’Reilly, late 2011
  • Goals Identify common Web implementation patterns Encourage you to re-think your habits Challenge existing frameworks & tooling Improve the quality of information on the Web
  • Non-Goals Explain the HTTP Protocol Defend the REST Style Promote/Denigrate any  Platform/OS  Programming Language  Web Library or Framework
  • My Hidden Agenda
  • When I get done,I hope there will be…
  • Less of this…
  • More of this…
  • “Vision without action is a daydream. Action without visionis a nightmare.”– Japanese Proverb
  • ROT
  • RepresentationalObjectTransfer
  • RepresentationalObjectTransfer
  • Object“In computer science, an object is anyentity that can be manipulated by thecommands of a programming language,such as a value, variable, function, or datastructure.”- Wikipedia
  • Why is this bad?
  • It’s a Web “anti-pattern”
  • Wait, it’s a what?
  • Anti-pattern “In software engineering, an anti- pattern (or antipattern) is a pattern that may be commonly used but is ineffective and/or counterproductive in practice.” - Wikipedia
  • Anti-pattern “In software engineering, an anti- pattern (or antipattern) is a pattern that may be commonly used but is ineffective and/or counterproductive in practice.” - Wikipedia
  • On the Web, ROTis ineffectiveand/orcounterproductive Object Serialization Type Marshaling
  • Type Marshaling Problems Updates on the server can break the clients  Objects/Members added/changed/removed Moving to a new server/domain can break the clients  Object IDs (URIs) added/change/removed Modifying the process flow can break the clients  Object processing added/changed/removed
  • On the Web,ROT doesn’t scale
  • This is NOT an HTTP Problem
  • This is the nature ofdistributed networks
  • Some examples please….
  • Schema Publishing ROT
  • Type Hints in the Payload ROT
  • URI Construction ROT
  • Object-Based Media Types ROT
  • They all suffer fromthe same shortcoming
  • They try to solvethe wrong problem
  • "How can a serversuccessfully export its privateobjects in a way thatclients can see and usethem?"Not the correct question…
  • "How cana server and client share acommon understanding ofthe payloads passed betweenthem?"Much better question…
  • We need to Stop sharing private objects Look beyond local “types” as sharing units Make it work across:  Platforms  Languages  FrameworksWe need acommon understanding
  • “Freedom lies in being bold.”- Robert Frost
  • REST
  • RepresentationalStateTransfer
  • RepresentationalStateTransfer
  • State“In computer science and automata theory,a state is a unique configuration ofinformation in a program or machine.”- Wikipedia
  • “State” is not an object.
  • The “Type-less” Web The Web has no local “types” The Web doesn’t need any. The Web has payloads  Message  Metadata
  • We share the “state” of an app,not the objects on the server.
  • Ok, how do we share “state”?
  • We pass messages…
  • That’s it?
  • Well…
  • Not just “any” messages…
  • We share “state” on the Webusing a “media type”
  • Media Types text/html, application/xml, application/json, etc Elements, attributes, properties, arrays, etc. Structured, well-formed, valid, etc. Independent of  Platform  Language  Framework
  • Actually, there is aspecial group of media typesthat are “best” for the Web…
  • Hyper-media Types.
  • Hypermedia Types Notjust “what” name, email, price, size, … Also“how” a, link, img, form, input, …
  • Hypermedia messagescontain H-Factors
  • H-Factors Servers include these to tell clients what they can do next… Link Factors Control Factors
  • Link Factors LE = Link Embedding  HTML.IMG LO = Link Outbound  HTML.A LT = Link Template  HTML.FORM[action=“get”] LN = Link Non-Idempotent  HTML.FORM[action=“post”] LI = Link Idempotent  HTML.FORM[action=“put”]
  • Control Factors CR = Control Reads  HTML.LINK[rel=“stylesheet”] CU = Control Updates  HTML.FORM[enctype=“text/plain”] CM = Control Methods  HTML.FORM[method=“post”] CL = Control Links  A[rel=“payment”]
  • On the Web,we share understandingusing media-types.
  • What do we understand?
  • What do we understand?
  • What do we understand?
  • What do we understand?
  • So we must designthe messages we share…
  • Design and Share Messages Where is the data? Where are the links? How can I send queries? How can I modify data?
  • And we must document thedesign…
  • And create servers thatunderstand the media type…
  • And write clients thatunderstand the media type…
  • That’s how the Web is meantto be played!
  • “The important thing is not to stop questioning.”- Albert Einstein
  • Stop Marshaling Types
  • Start Using Hypermedia
  • Start Designing Messages
  • Give us Less ROT and More REST
  • Enjoy the Benefits of the Web!
  • Mike Amundsen @mamund