Slide 1

Slide 1 text

BUILDING BETTER CLIENTS

Slide 2

Slide 2 text

BEN LONGDEN CTO Inviqa Enterprise open source

Slide 3

Slide 3 text

@BLONGDEN

Slide 4

Slide 4 text

There are two types of client

Slide 5

Slide 5 text

MACHINE DRIVEN

Slide 6

Slide 6 text

HUMAN DRIVEN

Slide 7

Slide 7 text

WHAT'S THE PROBLEM?

Slide 8

Slide 8 text

We're getting quite good better at building RESTful API's on the server side.

Slide 9

Slide 9 text

But what about our clients?

Slide 10

Slide 10 text

Do they allow the API to change?

Slide 11

Slide 11 text

Consider the web browser.

Slide 12

Slide 12 text

What would the browser do? — Brian Sletten

Slide 13

Slide 13 text

Supports the most common media types.

Slide 14

Slide 14 text

application/x-shockwave-flash

Slide 15

Slide 15 text

Versioning

Slide 16

Slide 16 text

HTML

Slide 17

Slide 17 text

We're not building a web browser

Slide 18

Slide 18 text

But we can be inspired

Slide 19

Slide 19 text

CONTENT NEGOTIATION (CONNEG)

Slide 20

Slide 20 text

Send what your client will accept

Slide 21

Slide 21 text

Accept: application/hal+json, text/plain

Slide 22

Slide 22 text

Check what the server sends back

Slide 23

Slide 23 text

Content-Type: application/hal+json

Slide 24

Slide 24 text

Allow clients to support new media types when they become available

Slide 25

Slide 25 text

Accept: application/hal+json, application/ vnd.error+json, text/plain;q=0.9

Slide 26

Slide 26 text

USE AN HTTP CLIENT

Slide 27

Slide 27 text

CACHEING

Slide 28

Slide 28 text

URLS

Slide 29

Slide 29 text

Remember that any GET request can be bookmarked by a client

Slide 30

Slide 30 text

But also that it could result in a redirect

Slide 31

Slide 31 text

GUZZLE ▸ Cacheing ▸ Logging ▸ Oauth

Slide 32

Slide 32 text

HYPERMEDIA CONSTRAINT

Slide 33

Slide 33 text

Hypermedia is defined by the presence of application control information embedded within, or as a layer above, the presentation of information — Roy Fielding

Slide 34

Slide 34 text

LINK RELATIONS POSSIBLE STATES

Slide 35

Slide 35 text

CONTEXT

Slide 36

Slide 36 text

{ "_links": { "self": { "href": "/comment/3864362" } }, "content": "lol" }

Slide 37

Slide 37 text

{ "_links": { "edit": { "href": "/comment/3864362" }, "self": { "href": "/comment/3864362" } }, "content": "lol" }

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

CLIENT CAN EVOLVE INDEPENDENTLY

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

Futureproof?

Slide 42

Slide 42 text

DESIGN OF EVERYDAY THINGS

Slide 43

Slide 43 text

Form a goal

Slide 44

Slide 44 text

Intention to act

Slide 45

Slide 45 text

Sequence of actions

Slide 46

Slide 46 text

Execution of the sequence of action

Slide 47

Slide 47 text

Perceive the state of the world

Slide 48

Slide 48 text

Interpret the perception

Slide 49

Slide 49 text

Evaluate the outcome

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

Why am I talking about this?

Slide 52

Slide 52 text

A hypermedia client works in much the same way

Slide 53

Slide 53 text

Let the server be in control

Slide 54

Slide 54 text

Use content negotiation to allow clients to evolve

Slide 55

Slide 55 text

Use an HTTP client and turn on cacheing

Slide 56

Slide 56 text

Drive human interaction through hypermedia controls

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

QUESTIONS! (or ask me at the bar later)