how the web evolves with hypermedia (whiskyweb2012 2012-04-13)

120
HOW THE WEB EVOLVES WITH HYPERMEDIA

Upload: david-zuelke

Post on 15-Jan-2015

688 views

Category:

Technology


0 download

DESCRIPTION

Closing keynote given at the Whisky Web Conference 2012 in Edinbugh, Scotland.

TRANSCRIPT

Page 1: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

HOW THE WEB EVOLVESWITH HYPERMEDIA

Page 2: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

David Zuelke

Page 3: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

David Zülke

Page 4: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 5: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 6: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

http://en.wikipedia.org/wiki/File:München_Panorama.JPG

Page 7: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

Founder

Page 9: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

Lead Developer

Page 12: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

THE WEBThe Internet’s Largest Application

Page 13: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

WWW

Page 14: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

first data exchange system

Page 15: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

planetary scale

Page 16: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 17: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 18: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

why is that possible?

Page 19: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

Hyperlinks!

Page 20: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

no tight coupling!

Page 21: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

Hyperlinks must not have an inverse

Page 22: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

loosely coupled by design

Page 23: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

embraces failure

Page 24: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

HTTP/1.1 404 Not Found

Page 25: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

no notification infrastructure

Page 26: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

more information != more friction

Page 27: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

no limits to scalability

Page 28: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

WWW is protocol-centric

Page 29: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

THE HUMAN WEBPoint and Click

Page 30: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

the Web changes

Page 31: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

1997

Page 32: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 33: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

2011

Page 34: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 35: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

but humans can adapt

Page 36: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 37: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 38: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

14+ years of search

Page 39: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

(and 14+ years of ugly design :p)

Page 40: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

THE HUMAN BRAINYou are a State Machine!

Page 41: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

bored

Page 42: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

want something awesome

Page 43: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 44: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 45: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

laaaaaame... what’s on the next pages?

Page 46: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 47: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 48: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 49: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 50: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 51: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

PROGRESSIVE INTERNATIONAL GMMC-68

✓ Makes something to eat

✓ Cool & evil company name

✓ like “Cyberdyne”

✓ or “Umbrella Corporation”

✓ GMMC-68 sounds like a Terminator model number

Page 53: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

awesome!

Page 54: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

let’s buy that

Page 55: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 56: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 57: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 58: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

let’s model that process

Page 59: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

while($david-­‐>isBored()&&!$david-­‐>isBroke()){    squeeze_pacman_stress_ball();        $amazon  =  new  Browser('http://amazon.com');    while(!$david-­‐>getIsHappy())  {        switch($amazon-­‐>state)  {            case  'home':  {                $amazon-­‐>search('awesome  stuff');            }  break;            case  'search_result_page':  {                if(!$amazon-­‐>hasSomethingAwesome())  {                    $amazon-­‐>followAwesomeProduct();                }  elseif($amazon-­‐>hasMorePages())  {                    $amazon-­‐>followNextPage();                }  else  {                    sleep(3600);                    $amazon-­‐>state  =  'home';  //  retry!                }            }  break;            case  'product_page':  {                $amazon-­‐>followAddToCart();            }  break;

           case  'shopping_cart':  {                $amazon-­‐>followCheckout();            }  break;            case  'login_or_register':  {                if($david-­‐>hasAmazonAccount())  {                    $amazon-­‐>followLogin();                }  else  {                    $amazon-­‐>followRegister();                }            }  break;            case  'order_summary':  {                $amazon-­‐>followConfirmation();            }  break;            case  'order_confirmation':  {                $david-­‐>setIsHappy(mt_rand(0,1));            }  break;            case  'default':  {                $amazon-­‐>state  =  'home';            }        }    }}

AS PSEUDOCODE

Page 60: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

that was easy

Page 61: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

interactions driven by human intelligence

Page 62: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

sometimes idiots drive the interaction

Page 63: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 64: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 65: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 66: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 67: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 68: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

Humans can adapt to changes and new things

Page 69: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

THE MACHINE WEBCan Computers Do This?

Page 70: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

CAN WE TEACH A COMPUTER TO...

• ... discover workflows the server offers?

• ... follow links to a “next page” until the right product is found?

• ... leniently handle...

• ... changes in organization of resources?

• ... newly added information or operations?

Page 71: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

yes

Page 72: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

it’s called REST

Page 73: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

unfortunately

Page 74: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

people fuck it up all the time

Page 75: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

they’re like

Page 76: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

I haz REST nao

Page 77: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

boss is happy

Page 78: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

VCs give money

Page 79: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

it’s like the insane cloud hype

Page 80: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 81: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

THE MACHINE BRAINHypermedia to the Rescue

Page 82: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)
Page 83: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

Hypermedia As The Engine Of Application State

Page 84: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

it’s the part people always miss

Page 85: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

I am getting frustrated by the number of people calling any HTTP-based interface a REST API [...]If the engine of application state (and hence the API) is not being driven by hypertext, then it cannot be RESTful and cannot be a REST API.

His Royness Fielding

Page 86: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

RPC/SOAP

Page 87: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

out-of-band knowledge drives interaction

Page 88: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

“you must call init() before execute()”

Page 89: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

HATEOAS

Page 90: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

hypermedia type has defined semantics

Page 91: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

clients follow links with known relations

Page 92: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

just like humans!

Page 93: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

<?xml  version="1.0"  encoding="utf-­‐8"  standalone="yes"?><search>    <total_results>9</total_results>    <items_per_page>1</items_per_page>    <start_index>1</start_index>    <link  href="http://openapi.lovefilm.com/catalog/games?start_index=1&amp;items_per_page=1&amp;term=old"                rel="self"  title="self"/>    <link  href="http://openapi.lovefilm.com/catalog/games?start_index=2&amp;items_per_page=1&amp;term=old"                rel="next"  title="next"/>    <link  href="http://openapi.lovefilm.com/catalog/games?start_index=9&amp;items_per_page=1&amp;term=old"                rel="last"  title="last"/>    <catalog_title>        <can_rent>true</can_rent>        <release_date>2003-­‐09-­‐12</release_date>        <title  full="Star  Wars:  Knights  of  the  Old  Republic"  clean="Star  Wars:  Knights  of  the  Old  Republic"/>        <id>http://openapi.lovefilm.com/catalog/title/59643</id>        <adult>false</adult>        <number_of_ratings>574</number_of_ratings>        <rating>4</rating>        <category  scheme="http://openapi.lovefilm.com/categories/catalog"  term="games"/>        <category  scheme="http://openapi.lovefilm.com/categories/format"  term="Xbox"/>        <category  scheme="http://openapi.lovefilm.com/categories/genres"  term="Adventure"/>        <category  scheme="http://openapi.lovefilm.com/categories/genres"  term="Role-­‐playing"/>        <category  scheme="http://openapi.lovefilm.com/categories/certificates/bbfc"  term="TBC"/>        <link  href="http://openapi.lovefilm.com/catalog/title/59643/synopsis"                    rel="http://schemas.lovefilm.com/synopsis"  title="synopsis"/>        <link  href="http://openapi.lovefilm.com/catalog/title/59643/reviews"                    rel="http://schemas.lovefilm.com/reviews"  title="reviews"/>        <link  href="http://www.lovefilm.com/product/59643-­‐Star-­‐Wars-­‐Knights-­‐of-­‐the-­‐Old-­‐Republic.html?cid=LFAPI"                    rel="alternate"  title="web  page"/>    </catalog_title></search>

Page 94: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

HTTP’s Uniform Interface is generic

Page 95: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

GET  /products/1234  HTTP/1.1Host:  evilshop.comAccept:  application/vnd.com.evilshop+xml

HTTP/1.1  200  OKContent-­‐Type:  application/vnd.com.evilshop+xml;  charset=utf-­‐8Allow:  GET,  PUT,  DELETE

<?xml  version="1.0"  encoding="utf-­‐8"?><product  xmlns="urn:com.evilshop.prod"  xmlns:atom="http://www.w3.org/2005/Atom">    <id>1234</id>    <name>Shark  with  Friggin’  Laser  Beams  Attached  to  its  Head</name>    <price  currency="EUR">3.14</price>    <atom:link  rel="category"  type="application/vnd.com.evilshop+xml"                          href="http://evilshop.com/categories/lasers"/></product>

Page 96: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

PUT  /products/1234  HTTP/1.1Host:  evilshop.comContent-­‐Type:  application/vnd.com.evilshop+xml

<?xml  version="1.0"  encoding="utf-­‐8"?><product  xmlns="urn:com.evilshop.prod"  xmlns:atom="http://www.w3.org/2005/Atom">    <id>1234</id>    <name>Shark  with  Friggin’  Laser  Beams  Attached  to  its  Head</name>    <price  currency="EUR">31414.14</price>    <atom:link  rel="category"  type="application/vnd.com.evilshop+xml"                          href="http://evilshop.com/categories/lasers"/></product>

HTTP/1.1  204  No  ContentContent-­‐Type:  application/vnd.com.evilshop+xml;  charset=utf-­‐8Allow:  GET,  PUT,  DELETE

Page 97: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

EVOLVABILITY(Creationists Better Leave Now)

Page 98: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

OO style or RPC style

Page 99: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

clients bound to object graph or procedures

Page 100: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

SOAP

Page 101: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

breaks all the clients, all the time

Page 102: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

expect the unexpected

Page 103: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

<?xml  version="1.0"  encoding="utf-­‐8"?><products  xmlns="http://acme.com/shop/products">    <product  id="123">        <name>Bacon</name>        <price>5.99</price>    </product></products>

Page 104: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

<?xml  version="1.0"  encoding="utf-­‐8"?><products  xmlns="http://acme.com/shop/products">    <product  id="123">        <name>Bacon</name>        <price>5.99</price>        OMNOMNOM  Bacon    </product></products>

Page 105: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

<?xml  version="1.0"  encoding="utf-­‐8"?><products  xmlns="http://acme.com/shop/products">    <product  id="123">        <name>Bacon</name>        <price>5.99</price>        <price  currency="EUR">4.49</price>    </product></products>

Page 106: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

<?xml  version="1.0"  encoding="utf-­‐8"?><products  xmlns="http://acme.com/shop/products">    <product  id="123">        <name  xml:lang="en">Bacon</name>        <name  xml:lang="de">Speck</name>        <price>5.99</price>    </product></products>

Page 107: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

<?xml  version="1.0"  encoding="utf-­‐8"?><products  xmlns="http://acme.com/shop/products">    <product  id="123">        <name  xml:lang="en">Bacon</name>        <name  xml:lang="de">Speck</name>        <price>5.99</price>        <link  rel="category"  href="..."  />    </product></products>

Page 108: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

and break only if you have to

Page 109: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

GET  /products/1234  HTTP/1.1Host:  evilshop.comAccept:  application/vnd.com.evilshop+xml

HTTP/1.1  200  OKContent-­‐Type:  application/vnd.com.evilshop+xml;  charset=utf-­‐8Allow:  GET,  PUT,  DELETE

<?xml  version="1.0"  encoding="utf-­‐8"?><product  xmlns="urn:com.evilshop.prod"  xmlns:atom="http://www.w3.org/2005/Atom">    <id>1234</id>    <name>Shark  with  Friggin’  Laser  Beams  Attached  to  its  Head</name>    <price  currency="EUR">3.14</price>    <atom:link  rel="category"  type="application/vnd.com.evilshop+xml"                          href="http://evilshop.com/categories/lasers"/></product>

Page 110: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

GET  /products/1234  HTTP/1.1Host:  evilshop.comAccept:  application/vnd.com.evilshop+xml

HTTP/1.1  200  OKContent-­‐Type:  application/vnd.com.evilshop+xml;  charset=utf-­‐8Allow:  GET,  PUT,  DELETE

<?xml  version="1.0"  encoding="utf-­‐8"?><product  xmlns="urn:com.evilshop.prod"  xmlns:atom="http://www.w3.org/2005/Atom">    <id>1234</id>    <name>Shark  with  Friggin’  Laser  Beams  Attached  to  its  Head</name>    <price  currency="EUR">3.14</price>    <description>Does  it  need  one?  :)</description>    <atom:link  rel="category"  type="application/vnd.com.evilshop+xml"                          href="http://evilshop.com/categories/lasers"/></product>

new field, not critical

Page 111: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

(sharks go out of stock...)

Page 112: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

GET  /products/1234  HTTP/1.1Host:  evilshop.comAccept:  application/vnd.com.evilshop+xml

HTTP/1.1  404  Not  FoundContent-­‐Type:  application/vnd.com.evilshop+xml;  charset=utf-­‐8Allow:  GET,  PUT,  DELETE

Page 113: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

“let’s remove the 404 and send an availability field”

Page 114: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

BC break, existing clients don’t know the field!

Page 115: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

Solution: a new Media Type version

Page 116: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

GET  /products/1234  HTTP/1.1Host:  evilshop.comAccept:  application/vnd.com.evilshop.2+xml,application/vnd.com.evilshop+xml;q=0.5

HTTP/1.1  200  OKContent-­‐Type:  application/vnd.com.evilshop.2+xml;  charset=utf-­‐8Allow:  GET,  PUT,  DELETE

<?xml  version="1.0"  encoding="utf-­‐8"?><product  xmlns="urn:com.evilshop.prod"  xmlns:atom="http://www.w3.org/2005/Atom">    <id>1234</id>    <available>false</available>    <name>Shark  with  Friggin’  Laser  Beams  Attached  to  its  Head</name>    <price  currency="EUR">3.14</price>    <atom:link  rel="category"  type="application/vnd.com.evilshop+xml"                          href="http://evilshop.com/categories/lasers"/></product>

Page 117: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

with this and HATEOAS, clients become unbreakable

Page 118: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

and the Web evolveswith Hypermedia

Page 119: How the Web Evolves with Hypermedia (WHISKYWEB2012 2012-04-13)

!e End