SLIDE 1
Designing for Reuse: Creating APIs for the Future Mike Amundsen, - - PowerPoint PPT Presentation
Designing for Reuse: Creating APIs for the Future Mike Amundsen, - - PowerPoint PPT Presentation
Designing for Reuse: Creating APIs for the Future Mike Amundsen, Layer 7 / CA @mamund Introduction The Challenge Versioning Content removed by authors request Content removed by authors request Deprecate version after a year Content
SLIDE 2
SLIDE 3
SLIDE 4
SLIDE 5
SLIDE 6
The Challenge
SLIDE 7
SLIDE 8
SLIDE 9
Versioning
SLIDE 10
SLIDE 11
Content removed by author’s request
SLIDE 12
Content removed by author’s request
SLIDE 13
SLIDE 14
Deprecate version after a year
SLIDE 15
Content removed by author’s request
SLIDE 16
Content removed by author’s request
SLIDE 17
SLIDE 18
They release a new version every 120 days
SLIDE 19
Currently supporting 20+ parallel versions
SLIDE 20
Content removed by author’s request
SLIDE 21
Content removed by author’s request
SLIDE 22
SLIDE 23
No breaking changes
SLIDE 24
Content removed by author’s request
SLIDE 25
To Version means "to turn"
SLIDE 26
SLIDE 27
There's another word for backward- compatible versioning...
SLIDE 28
SLIDE 29
Backward-compatible versioning is essentially creating extensions
SLIDE 30
SLIDE 31
So, how do you enable backward- compatible API extensions?
SLIDE 32
I'll talk about two ways today...
SLIDE 33
Messages (on the wire)...
SLIDE 34
Implementation (in the code)
SLIDE 35
Message Design
SLIDE 36
Extending Messages
SLIDE 37
Extending Messages
SLIDE 38
Extending messages let's you easily add backward-compatible changes
SLIDE 39
Structure vs Data
SLIDE 40
Structure vs Data
SLIDE 41
Focus on passing data, not structure
SLIDE 42
SLIDE 43
There are several new formats designed specifically for passing data
- n the Web
SLIDE 44
SLIDE 45
SLIDE 46
SLIDE 47
SLIDE 48
SLIDE 49
What's the common theme in these new designs?
SLIDE 50
Message over Object
SLIDE 51
"[I]t is far easier to standardize representation and relation types than it is to standardize objects and
- bject-specific
interfaces."
- Roy T. Fielding
SLIDE 52
The most common data-passing format
- n the Web is…
SLIDE 53
The most common data-passing format
- n the Web is…
SLIDE 54
SLIDE 55
Because it is easy to extend.
SLIDE 56
Message design is not the only place to plan for extensions
SLIDE 57
Implementation Design
SLIDE 58
Component != Connector
SLIDE 59
Component
▪ Database ▪ File System ▪ Message Queue ▪ Transaction Manager ▪ Source Code
SLIDE 60
Component == IP
SLIDE 61
Component == $$$
SLIDE 62
Component == Private
SLIDE 63
Connector
▪ Web Server ▪ Browser Agent ▪ Proxy Server ▪ Shared Cache
SLIDE 64
Connector == Shared Tech
SLIDE 65
Connector == Commodity
SLIDE 66
Connector == Public
SLIDE 67
Keep Connectors and Components separated
SLIDE 68
Implementation Stack
SLIDE 69
Implementation Stack
SLIDE 70
Implementation Stack
SLIDE 71
Implementation Stack
SLIDE 72
Class Schedule Server
SLIDE 73
SLIDE 74
SLIDE 75
SLIDE 76
SLIDE 77
SLIDE 78
SLIDE 79
Each of these implmentation elements can be updated independently w/o breakage
SLIDE 80
Client Strategies
SLIDE 81
Most client apps are bound to URIs and the CRUD pattern
SLIDE 82
URI-Style Clients (CRUD)
- HTML SPA Container
SLIDE 83
URI-Style Clients (CRUD)
- URIs, Objects, and Actions
SLIDE 84
URI-Style Clients (CRUD)
- URIs, Objects, and Actions
SLIDE 85
URI-Style Clients (CRUD)
- URIs, Objects, and Actions
SLIDE 86
URI-Style Clients (CRUD)
- Composed HTML
SLIDE 87
URI-Style Clients (CRUD)
- JS Summary
SLIDE 88
A better approach is to bind to the message.
SLIDE 89
Hypermedia Client (REST)
- HTML FSM Container
SLIDE 90
Hypermedia Client (REST)
- Media Types and Controls
SLIDE 91
Hypermedia Client (REST)
- Media Types and Controls
SLIDE 92
Hypermedia Client (REST)
- Composed HTML
SLIDE 93
Hypermedia Client (REST)
- Summary JS
SLIDE 94
Message over Object
SLIDE 95
The Lessons of HTTP
SLIDE 96
You never get it right the first time...
SLIDE 97
SLIDE 98
SLIDE 99
SLIDE 100
SLIDE 101
SLIDE 102
SLIDE 103
SLIDE 104
SLIDE 105
So, lots of changes to the protocol over the last 15 years and...
SLIDE 106
It's all backward compatible!
SLIDE 107
"If you want a protocol to last a few decades, don't assume too much."
- Roy Fielding
SLIDE 108
So the real lesson in all this?
SLIDE 109
SLIDE 110
So...
SLIDE 111
- Use the extension pattern
- Keep structure in messages low
- Consider new message-based media types
- form-urlencoded is still a winner
- Commit to no "breaking changes"
Message Design...
SLIDE 112
- Keep component and connectors apart
- Use representors
- Make sure storage, biz, representors, and
routers can change w/o breakage
Server Implementation...
SLIDE 113
- Bind to messages, not objects/actions
- Code defensively, don't assume
- Make sure requestor can convert messages
into internal objects as needed
Client Implementation...
SLIDE 114
- You won't get it right the first time
- Build support for extensions into your work
- If you need to change it once, you might
need to change it often.
The lessons from HTTP
SLIDE 115
SLIDE 116