Global Bank Integration                The	  Counterintuitive	  Web	                                Ian	  Robinson	  http:...
Resources	  are	  information	  resources,	  not	  domain	  objects	                                          Person	     ...
Design	  smell:	  overloaded	  POST	       Overloaded	  POST	       Server	  has	  to	  peer	  inside	  entity	  body	    ...
Design	  smell:	  other	  overloads	       Other	  overloads	       Server	  has	  to	  interrogate	  resource	  state	  p...
Operation-­‐oriented	  vs.	  resource-­‐oriented	  design	       CreateOrder	                                            S...
Specialization	  and	  innovation	  depend	  on	  an	  open	  set	                                                        ...
HTTP	  verbs	          Verb	             Safe?	          Idempotent?	            Description	          GET	               ...
DELETE	  !=	  cancel:	  don’t	  map	  domain	  operations	  onto	  verbs	          HTTP	  verbs	  are	  the	  humble	  ser...
Clients	  deal	  with	  URIs	  (and	  representations),	  not	  resources	    Resources	  can	  be	  iden.fied	  and	  addr...
Design	  smell:	  overloaded	  POST	       Overloaded	  POST	       Server	  has	  to	  peer	  inside	  entity	  body	    ...
Design	  smell:	  other	  overloads	       Other	  overloads	       Server	  has	  to	  interrogate	  resource	  state	  p...
Intention	  should	  be	  “written	  on	  the	  wire”	            Part	                                      Description	 ...
Guaranteed	  delivery?	  GET	  it	  yourself	                Order	  	              Management	                           ...
HTTP	  =	  ???	  
HTTP:	  an	  application	  transfer	  protocol	            Term	                                   Description	           ...
Benefits	                 Coordination	  protocol	  (status	  codes)	                                        +	            ...
GET	  connected:	  design	  for	  caching	                                                          Inside	  corporate	  fi...
Cache	  by	  freshness	                                                                  Server/        Client	      Local...
A	  web	  of	  data	                                          @mfeathers:	  Good	  OO	  =	  Tell,	  dont	  ask.	  Good	  F...
Facts:	  that’s	  data,	  and	  CRUD,	  right?	           “[our	  customers]	  base	  their	  success	  on	               ...
Achieving	  balance:	  design	  and	  implementation	  guidelines	      1. Design	  applica.ons	  in	  terms	  of	        ...
Application	  protocol,	  application	  state	                                        Application	  protocol	             ...
Order	  fulfillment	  application	  protocol	                              awaiting                            fulfillment ...
Order	  fulfillment	  protocol	  resources	                                        details                  contains       ...
Resource	  state	  is	  a	  function	  of…	       1.  Value	  of	  information	  items	  belonging	  to	  resource	       ...
Information	  resources	  ≈	  protocol	  resources	       Of	  course,	  if	  you	  do	  want	  a	  CRUD	  protocol	  for	...
Benefits	  of	  this	  approach	        Rich	  protocol	  semantics	        Networked	  resources	  realize	  an	  applicat...
Drawbacks	       Federation	  adds	  complexity	       Application	  protocol	  is	  not	  encapsulated	  “as	  such”	    ...
Contracts	  =	  link	  relations	  +	  media	  types	  +	  HTTP	  idioms	                         Part	                   ...
Specification	    Entry	  point  Media	  type	    application/vnd.restbucks+xml  Resou...
Specification	  (continued)	    Link	  relations	      edit     The	  linked	  resource	  can	  be	  used	  to	  edit	  the...
Except…	                 On	  the	  Web	  there	  are	  laws,	  	                  but	  no	  legal	  frameworks	      “Re...
Summary	       Clients	  care	  more	  about	                                 HTTP	  makes	  the	  client	       URIs	  an...
Hypermedia	  and	  Systems	  Architecture	      Coming	  August	  2010	      h@p://	    ...
Can	  we	  count	  you	  in?	  
Thank	  you	  @ianSrobinson	  
Upcoming SlideShare
Loading in...5

The counter intuitive web (Ian robinson)


Published on

Published in: Technology, Design
1 Like
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

The counter intuitive web (Ian robinson)

  1. 1. Global Bank Integration The  Counterintuitive  Web   Ian  Robinson  @ianSrobinson  
  2. 2. Resources  are  information  resources,  not  domain  objects   Person   Resource   Person   Order   Resource   Order  
  3. 3. Design  smell:  overloaded  POST   Overloaded  POST   Server  has  to  peer  inside  entity  body   POST /orders/123 HTTP/1.1 Host: <loyalty-card> ... </loyalty-card> POST /orders/123 HTTP/1.1 Host: <drink> ... </drink>
  4. 4. Design  smell:  other  overloads   Other  overloads   Server  has  to  interrogate  resource  state  prior  to   dispatching  to  appropriate  handler   getState() Cancel   DELETE /orders/123 HTTP/1.1 Host: DELETE /orders/123 HTTP/1.1 Complete   Host: cancel()
  5. 5. Operation-­‐oriented  vs.  resource-­‐oriented  design   CreateOrder   SearchOrders   Operations   AmendOrder   ReserverOrder   CompleteOrder   CancelOrder   RemoveDrink   AddDrink   GET   GET   Resources   PUT   PUT   GET   POST   POST   PUT   DELETE   DELETE   POST   Drink   DELETE   Order   Fulfillment  
  6. 6. Specialization  and  innovation  depend  on  an  open  set   CreateOrder   SearchOrders   AddDrink   ReserverOrder   CompleteOrder   CancelOrder   AmendOrder   RemoveDrink   GET   PUT   POST   DELETE   GET   PUT   POST   DELETE  
  7. 7. HTTP  verbs   Verb   Safe?   Idempotent?   Description   GET   √   √   Retrieve  representation   PUT   χ   √   Store  representation   χ   χ   Annotate,  append  to   POST   resource  identified  by  URI   DELETE   χ   √   Delete  resource   Safe   No  side-­‐effects  for  which  client  is  responsible   Idempotent   “Absolute”  side  effects  
  8. 8. DELETE  !=  cancel:  don’t  map  domain  operations  onto  verbs   HTTP  verbs  are  the  humble  servants  of   the  hypermedia  state  apparatus   Stable,  well-­‐understood  characteristics   Safety   Idempotency   Do  the  same-­‐old-­‐same-­‐old  in  the  same-­‐old  way   Transferring  representations  of  state   No  surprises   No  additional  semantics   No  innovation  
  9. 9. Clients  deal  with  URIs  (and  representations),  not  resources   Resources  can  be  iden.fied  and  addressed  by  mul.ple  URIs ? Problems   Cannot  determine  URI  equality   Cache  invalidation  
  10. 10. Design  smell:  overloaded  POST   Overloaded  POST   Server  has  to  peer  inside  entity  body   POST /orders/123 HTTP/1.1 POST /orders/123/discounts HTTP/1.1 Host: Host: <loyalty-card> <loyalty-card> ... ... </loyalty-card> </loyalty-card> POST /orders/123 HTTP/1.1 POST /orders/123 HTTP/1.1 Host: Host: <drink> <drink> ... ... </drink> </drink>
  11. 11. Design  smell:  other  overloads   Other  overloads   Server  has  to  interrogate  resource  state  prior  to   dispatching  to  appropriate  handler   getState() Cancel   DELETE /orders/123 HTTP/1.1 Host: Cancel   DELETE /orders/123 HTTP/1.1 Complete   Host: HTTP/1.1 DELETE /orders/123 cancel() Host: cancel() Complete   POST /orders/123/end HTTP/1.1 complete() Host:
  12. 12. Intention  should  be  “written  on  the  wire”   Part   Description   URI   Identifies  target  of  request   Document-­‐oriented  method  semantics,  plus   Verb   idempotency  and  safety  expectations   Accept/ Preferred  representation  format  and   Content-­‐Type   information  element  processing  model   Other  headers   Additional  processing  context  
  13. 13. Guaranteed  delivery?  GET  it  yourself   Order     Management   Co-­‐located,  time-­‐ordered  entries   No  lost  or  out-­‐of-­‐order  messages   GET  is  safe  and  idempotent   Atom  Client   Same  result   Different  data Product   Management   Atom  icons  from  
  14. 14. HTTP  =  ???  
  15. 15. HTTP:  an  application  transfer  protocol   Term   Description   Transacted  at  application  layer  of  network   Application   stack,  in  user  agent  and  server  software   For  the  purpose  of  coordinating  the  transfer   Transfer   of  documents   According  to  rules  that  determine  legitimate   Protocol   interactions  between  client  and  server  
  16. 16. Benefits   Coordination  protocol  (status  codes)   +   Self-­‐describing  processing  context  (headers)   +   Safety  and  idempotency  characteristics  (verbs)   Optimize  for  the  common  case   =   GET  
  17. 17. GET  connected:  design  for  caching   Inside  corporate  firewall   Standalone  (intermediary)   Server   Caching  proxy   Local  cache   Reverse  proxy   Client   Service  scalability   Memory   Disk  
  18. 18. Cache  by  freshness   Server/ Client   Local  cache   Cache   Client   Cache   Server   See  also:  
  19. 19. A  web  of  data   @mfeathers:  Good  OO  =  Tell,  dont  ask.  Good  FP  =   Ask,  dont  tell.  #speakerconf   OO  relationship  between  things,  FP  relationship   between  facts  (@marick)  #speakerconf   Web  is  the  applica.on  of  data  to  a   user  or  applica.on  goal   Residual  data  structures  to  be   completed  by  the  transfer  of  another   representa.on  of  state  
  20. 20. Facts:  that’s  data,  and  CRUD,  right?   “[our  customers]  base  their  success  on   us  failing  in  the  same  way”   “Instead  of  being  behavior-­‐centric  with   our  computer  systems,  we  look  at  them   as  just  being  CRUD,   and  we  basically  say  we  are  going  to   ignore  the  fact  that  we  are  going  to  do   anything  with  them”   Greg  Young  on  Our  Grand  Failure   h@p://  
  21. 21. Achieving  balance:  design  and  implementation  guidelines   1. Design  applica.ons  in  terms  of   applica&on  protocol  state  machines     2. Implement  them  in  terms  of  resource   lifecycles  and  the  rules  that  associate   resources   3.  them  using  media   types,  link  rela&on  values  and  HTTP   idioms   Web  
  22. 22. Application  protocol,  application  state   Application  protocol   Application  state  
  23. 23. Order  fulfillment  application  protocol   awaiting fulfillment remove barista drink accepts add drink fulfilling correcting order drinks == line items modified fulfilled
  24. 24. Order  fulfillment  protocol  resources   details contains fulfillment items not in details started created requires corrected preparing amending destroyed completed placed made discarded fulfilling fulfillment = consumed completed ready order drink
  25. 25. Resource  state  is  a  function  of…   1.  Value  of  information  items  belonging  to  resource   2.  Application  of  business  rules  that  relate  a  resource   to  other  resources   GET   See  also  FOREST:  Functional  Observer  REST   http://duncan-­‐­‐functional-­‐observer-­‐rest/  
  26. 26. Information  resources  ≈  protocol  resources   Of  course,  if  you  do  want  a  CRUD  protocol  for  an   anemic  domain…   notes implies   reading notes create note delete update note note note note created update delete note note note reading note deleted note updated
  27. 27. Benefits  of  this  approach   Rich  protocol  semantics   Networked  resources  realize  an  application  protocol   Architectural  properties   Loosely  coupled  (uniform  interface)   Fault  tolerant  (stateless,  self-­‐contained  requests)   Stateless  (application  state)   We’re  not  implementing  a  process  resource   Horizontally  scalable  
  28. 28. Drawbacks   Federation  adds  complexity   Application  protocol  is  not  encapsulated  “as  such”   Cache  invalidation   Resource  dependencies  complicate  cache  invalidation  
  29. 29. Contracts  =  link  relations  +  media  types  +  HTTP  idioms   Part   Description   What  is  the  meaning  of  the  linked  resource   Why   Link  relations   in  the  context  of  the  current   representation?  How   What   What  representation  formats  and  information   Media  types   element  processing  models  does  a  resource   recommend?   Which  HTTP  idioms  must  be  used  to  transfer   HTTP  idioms   representations  to/from  a  resource?   +  entry  point  URI(s)  
  30. 30. Specification   Entry  point Media  type   application/vnd.restbucks+xml Resources   Name   Description   Order   <status> values:  placed,  fulfilling,  ready.   Items   Order  line  items.   <status> values:  started,  requires-amending,   Fulfillment   preparing,  completed.   Drink   Prepared  drinks.  
  31. 31. Specification  (continued)   Link  relations   edit The  linked  resource  can  be  used  to  edit  the  link’s  context.   To  edit  order  details,  PUT  new  order  details  to  the  edit  link.   To  remove  a  drink  from  an  order,  DELETE the  linked  resource. Identifies  the  order  with  which  the  link  context  is  associated. Identifies  the  details  of  the  order  with  which  the  link  context  is  associated. Identifies  an  instance  of  fulfillment  of  the  link  context.     The  linked  resource  includes  an  ETag header.     Adding  new  drinks  should  be  done  with  a  conditional  POST.  If  the  fulfillment   instance  requires  amending  before  a  new  drink  can  be  added,  the  service  responds   with  412 Precondition Failed.  
  32. 32. Except…   On  the  Web  there  are  laws,     but  no  legal  frameworks   “Representation  metadata  does  not  constrain   the  receiving  agent  to  process  the   representation  data  in  one  particular  way”­‐respect  
  33. 33. Summary   Clients  care  more  about   HTTP  makes  the  client   URIs  and  representations   responsible  for  the   than  they  do  about  the   integrity  of  a  sequence  of   integrity  of  the  resource   requests,  which  is  a  good   space   thing  at  scale   Implement  application   protocols  (processes)  as   protocol  resources,  not   domain  resources  
  34. 34. Hypermedia  and  Systems  Architecture   Coming  August  2010   h@p://   Jim  Webber   Savas  Parastatidis   Ian  Robinson  
  35. 35. Can  we  count  you  in?  
  36. 36. Thank  you  @ianSrobinson  
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.