battelfield rest, api development from the trenches

50
Battlefield REST API's from the trenches Daniel Cerecedo @dcerecedo

Upload: daniel-cerecedo

Post on 20-Jun-2015

361 views

Category:

Software


0 download

DESCRIPTION

In this presentation we discuss the decisions that brought us to API development and why we focus just on delivering solutions around this technology. We discuss the implications of organizational learning and defining a systematic approach to API development with the goal of being able to automate as much as we can of the software development process. Eventually, we discuss the implementation choices we have made to accommodate advanced REST API requirements and the need to extend existing tooling.

TRANSCRIPT

Page 1: Battelfield REST, API Development from the trenches

Battlefield RESTAPI's from the trenches

Daniel Cerecedo@dcerecedo

Page 2: Battelfield REST, API Development from the trenches

AgendaStrategic DriversTactical Choices

LanguageFramework dilemmaTools

Down to the trenchesURIsRepresentationsHypermediaViewsUpdates & Concurrency

Next Steps@dcerecedoByteflair

Page 3: Battelfield REST, API Development from the trenches

Strategic Drivers

@dcerecedoByteflair

Page 4: Battelfield REST, API Development from the trenches

Strategic DriversAgility & Flexibility

Heraclitus

@dcerecedoByteflair

“There is nothing permanent but change”

Page 5: Battelfield REST, API Development from the trenches

Strategic DriversGrowth

@dcerecedoByteflair

Page 6: Battelfield REST, API Development from the trenches

Strategic Drivers

RESTful Web Services

@dcerecedoByteflair

Page 7: Battelfield REST, API Development from the trenches

Strategic Drivers

Service dependabilityTime to market

Quality

@dcerecedoByteflair

Page 8: Battelfield REST, API Development from the trenches

Strategic DriversPutting it all together

@dcerecedoByteflair

QualityDependability

SpeedCost

Page 9: Battelfield REST, API Development from the trenches

Strategic Drivers

Jack of all trades,Master of none

Achieving dependability

@dcerecedoByteflair

Page 10: Battelfield REST, API Development from the trenches

Strategic DriversClimb faster, deliver faster

@dcerecedoByteflair

Automate

Page 11: Battelfield REST, API Development from the trenches

Strategic DriversPutting it all together

@dcerecedoByteflair

Deve

lopme

nt Co

sts

# Projects Executed

Every time output is doubledcost per unit falls by 15%

Page 12: Battelfield REST, API Development from the trenches

“1.000 days to develop,

10.000 days to polish”

@dcerecedoByteflair

Miyamoto Mushashi

Page 13: Battelfield REST, API Development from the trenches

Tactical Choices

@dcerecedoByteflair

Page 14: Battelfield REST, API Development from the trenches

@dcerecedoByteflair

“Weapons should be adapted to your personal qualities and be

one you can handle”

Tactical Choices

Miyamoto Mushashi

Page 15: Battelfield REST, API Development from the trenches

Tactical ChoicesJava & Spring

@dcerecedoByteflair

Community, Availability & Quality of Libraries

Scalability & Deployability

Object Oriented & Type Safe

We are already good at it

Page 16: Battelfield REST, API Development from the trenches

Tactical Choices

@dcerecedoByteflair

Here, we do it the PHP way

Page 17: Battelfield REST, API Development from the trenches

Tactical Choices

@dcerecedoByteflair

SpeedFlexibility

The framework dilemma

Page 18: Battelfield REST, API Development from the trenches

Tactical Choices

@dcerecedoByteflair

Tools

Swagger

Postman

Page 19: Battelfield REST, API Development from the trenches

“It is deplorable to

die with weapons left in

their scabbards”

@dcerecedoByteflair

Miyamoto Mushashi

Page 20: Battelfield REST, API Development from the trenches

Down to the trenches

@dcerecedoByteflair

Page 21: Battelfield REST, API Development from the trenches

URIs

@dcerecedoByteflair

Page 22: Battelfield REST, API Development from the trenches

URIs

What is the resource?/collection/{id}

Default

@dcerecedoByteflair

Page 23: Battelfield REST, API Development from the trenches

URIs

What is the resource?/collection;id={id}

/collection;slug={slug}/collection/{id};field={fieldName}

Multiple Id's

@dcerecedoByteflair

Page 24: Battelfield REST, API Development from the trenches

URIs

B has unique ids within AB has universal unique ids

A B1 N

Nesting

@dcerecedoByteflair

Page 25: Battelfield REST, API Development from the trenches

URIs

What is the resource and context?/collection_a/{aid}/collection_b/{bid}

A B1 N

Nesting – Unique Id's within A

@dcerecedoByteflair

Page 26: Battelfield REST, API Development from the trenches

URIs

What is the resource and context?/collection_a/{aid}/collection_b/

/collection_a/{aid}/collection_b/{bid}/collection_b/{bid}

A B1 N

Nesting – Universal Unique Id's

@dcerecedoByteflair

Page 27: Battelfield REST, API Development from the trenches

URIs

Why provide context to universal id's?

Faster queries in NoSQL(nested docs)

{ }@dcerecedoByteflair

Page 28: Battelfield REST, API Development from the trenches

URIs

A BN N

Nesting – Universal Unique Id's

A C1 N B1 N

@dcerecedoByteflair

...and apply the same recipe

...normalize...

Page 29: Battelfield REST, API Development from the trenches

URIsNesting – A note on Users

@dcerecedoByteflair

/users/{uid}/collection_b/{bid}

For the connected user:/collection_b/{bid}

Page 30: Battelfield REST, API Development from the trenches

URIsCalculations

@dcerecedoByteflair

Create a ficticious resource

Page 31: Battelfield REST, API Development from the trenches

Representation

@dcerecedoByteflair

Page 32: Battelfield REST, API Development from the trenches

Representation

HTTP Status CodeHTTP Headers

HTTP Response Body

Overloading HTTP

@dcerecedoByteflair

Page 33: Battelfield REST, API Development from the trenches

Representation

HTTP Status Code

Success Error

Identifying Response Outcome

@dcerecedoByteflair

Page 34: Battelfield REST, API Development from the trenches

Representation

HTTP Status provides contextResponse Body provides detail

{“code”: 123,“message”: “ source of the problem”,“hint”: “give me ways to overcome this obstacle”

}

Error

@dcerecedoByteflair

Page 35: Battelfield REST, API Development from the trenches

Representation

{“error”: null,“data”: { …}

}

Error

{“error”: { … },“data”: null

}

NO

@dcerecedoByteflair

Page 36: Battelfield REST, API Development from the trenches

Representation

{“field_a”: “value”,“field_b”: value,

...}

Success

@dcerecedoByteflair

[{…},{…},

...]

Page 37: Battelfield REST, API Development from the trenches

Representation

{“size” : 7,“data”: [

{…},{…},...

]}

Error

NO

@dcerecedoByteflair

Page 38: Battelfield REST, API Development from the trenches

Representation

If there is no need to wrap responsesDon't do it

@dcerecedoByteflair

Page 39: Battelfield REST, API Development from the trenches

Representation

HTTP HeadersElements in the array

Any metadata about the current response

@dcerecedoByteflair

Metadata

Page 40: Battelfield REST, API Development from the trenches

Representation

@dcerecedoByteflair

Expansion and Projections

Don't be opinionated about the client

Page 41: Battelfield REST, API Development from the trenches

Representation

@dcerecedoByteflair

Views

Page 42: Battelfield REST, API Development from the trenches

Representation

@dcerecedoByteflair

Updates & Concurrency

Page 43: Battelfield REST, API Development from the trenches

Hypermedia

@dcerecedoByteflair

Page 44: Battelfield REST, API Development from the trenches

Hypermedia

@dcerecedoByteflair

SHOW METHE MONEY

Page 45: Battelfield REST, API Development from the trenches

Hypermedia

@dcerecedoByteflair

URI's are Id's

“id” : “5ef321”

“id” : { “_link”: “http://api.domain.com/collection/5ef321”

}

“id” : “http://api.domain.com/collection/5ef321”

Page 46: Battelfield REST, API Development from the trenches

Hypermedia

@dcerecedoByteflair

Referencing “author” : {

“_link”: “http://api.domain.com/users/5ef321” }

“messages” : [ { “_link”: “http://api.domain.com/picks/3976dh

}, {

“_link”: “http://api.domain.com/picks/3976dh }, ...]

Page 47: Battelfield REST, API Development from the trenches

Hypermedia

HTTP HeadersPagination links

Link to the created resource

@dcerecedoByteflair

Metadata

Page 48: Battelfield REST, API Development from the trenches

Moving On

@dcerecedoByteflair

Page 49: Battelfield REST, API Development from the trenches

@dcerecedoByteflair

“Be victorious today

over what you were

yesterday”Miyamoto Mushashi

Page 50: Battelfield REST, API Development from the trenches

?Daniel Cerecedo

@dcerecedo