SlideShare a Scribd company logo
1 of 67
Download to read offline
EMBRACING CHANGE
KYLE FULLER
POLLS
HOW DOES IT
WORK?
GET
/questions
DELETE
/questions/{id}
GET
/questions/{id}
POST/questions/{id}/choices/{choice_id}
POST
/questions
APPLICATION WAS BUILT
FROM AN OUT-OF-BAND
SPECIFICATION
TIGHT COUPLING
WE WANT TO
CHANGE
SOMETHING.
YOUR BOSS FINDS YOU LATE ON A
FRIDAY AFTERNOON
I'D LIKE TO...
> Add validation to create question with a minimum of 2
choices
> Add a minimum or maximum length to questions
> Change delete so only admins can delete questions
> Change delete so you can only delete your own
questions
> Change delete so you can't delete the initial questions
> Change vote so you can only vote once per question
> Change vote so any new votes override old votes on
the same question
> Add a new report question feature
THIS WILL TAKE SOME
TIME...
BUSINESS LOGIC
I HAVE TO REWRITE X
"ANTICIPATING CHANGE IS ONE OF THE
CENTRAL THEMES OF REST"
REPRESENTATIONAL
STATE TRANSFER
OUR APIhttps://polls.apiblueprint.org/
OUR API
> Questions (affordance)
QUESTIONS
> questions
> create (affordance)
QUESTION
> question
> choices
> delete (affordance)
> report (affordance)
CHOICE
> choice
> votes (count)
> vote (affordance)
SEMANTICSNOT IMPLEMENTATION DETAILS
$ curl https://polls.apiblueprint.org/
{"questions_url": "/questions", "url": "/"}
HAL
application/hal+json
HAL
$ curl https://polls.apiblueprint.org/ -H 'Accept: application/hal+json'
{
"_links": {
"questions": { "href": "/questions" },
"self": { "href": "/" }
}
}
HAL
$ curl https://polls.apiblueprint.org/questions/1
-H 'Accept: application/hal+json'
{
"question": "Favourite programming language?",
"_links": {"self": {"href": "/questions/1"}},
"_embed": {
"choices": [
{
"_links": {"self": {"href": "/questions/1/choices/1"}},
"choice": "Swift",
"votes": 483
}
]
}
}
$ curl https://polls.apiblueprint.org/questions -H 'Accept: application/hal+json'
{
"_links": {
"first": {"href": "/questions"},
"self": {"href": "/questions"},
"next": {"href": "/questions?page=2"}
"last": {"href": "/questions?page=2"},
},
}
SIREN
application/siren+json
SIREN
{
"actions": [
{
"name": "vote",
"href": "/questions/1/choices/3",
"method": "POST"
}
]
}
SIREN
{
"actions": [
{
"name": "create",
"method": "POST",
"type": "application/json",
"href": "/questions",
"fields": [
{ "name": "question", "type": "text", "title": "Question" },
{ "name": "choices", "type": "array[text]", "title": "Choices" }
]
}
]
}
HYPERDRIVE
API BLUEPRINT + HYPERDRIVE
API BLUEPRINT
## Questions Collection [/questions]
### Create a new question [POST]
+ Relation: create
+ Request (application/json)
+ Attributes
+ question (string, required)
+ choices (array[string], required)
+ Response 201 (application/json)
+ Attributes (Question)
HYPERDRIVE
hyperdrive.enter("https://polls.apiblueprint.org/") { result
}
REPRESENTOR
DEMO
hyperdrive.enter("http://localhost:8000/")
// follow the 'questions' transition
.flatMap { hyperdrive.request($0.transitions["questions"]) }
// Follow the 'create' transition
.flatMap {
hyperdrive.request($0.transitions["create"], attributes: [
"question": "types of egg",
"choices": ["hard boiled eggs", "soft boiled eggs"]
])
}
// Select the first choice
.map { $0.representors["choices"]!.first! }
// Follow the 'vote' transition
.flatMap { hyperdrive.request($0.transitions["vote"]) }
DEMO
/// Returns whether the user may create a question
var canCreateQuestion: Bool {
return representor.transitions["create"] != nil
}
/// Returns whether the user may delete the question at the given index
func canDeleteQuestion(index: Int) -> Bool {
let transition = questions?[index].transitions["delete"]
return transition != nil
}
import JSONSchema
let schema = Schema([
"type": "object",
"properties": [
"question": ["type": "string"],
"choices": ["type": "array", "minItems": 2],
],
])
schema.validate([
"question": "Favourite Conference?",
"choices": [
"MBLTDev 2015"
]
])
> the-hypermedia-project / Hyperdrive
> kylef / Starship, RxHyperdrive, JSONSchema.swift
> apiaryio / polls-app, polls-api
> kylefuller
> kyle @ fuller.li
> fuller.li / slides

More Related Content

Viewers also liked

MBLT15: Alexey Chikov, Kaspersky Lab
MBLT15: Alexey Chikov, Kaspersky LabMBLT15: Alexey Chikov, Kaspersky Lab
MBLT15: Alexey Chikov, Kaspersky Labe-Legion
 
MBLTDev15: Sergey Semenov, Trucker Path
MBLTDev15: Sergey Semenov, Trucker Path MBLTDev15: Sergey Semenov, Trucker Path
MBLTDev15: Sergey Semenov, Trucker Path e-Legion
 
MBLTDev15: Ivan Kozlov, Aviasales
MBLTDev15: Ivan Kozlov, AviasalesMBLTDev15: Ivan Kozlov, Aviasales
MBLTDev15: Ivan Kozlov, Aviasalese-Legion
 
MBLT15: Ivan Kozlov, Aviasales
MBLT15: Ivan Kozlov, AviasalesMBLT15: Ivan Kozlov, Aviasales
MBLT15: Ivan Kozlov, Aviasalese-Legion
 
MBLT15: Yakov Zubarev, Parallels
MBLT15: Yakov Zubarev, ParallelsMBLT15: Yakov Zubarev, Parallels
MBLT15: Yakov Zubarev, Parallelse-Legion
 
MBLTDev: Phillip Connaughton, RunKepper
MBLTDev: Phillip Connaughton, RunKepper MBLTDev: Phillip Connaughton, RunKepper
MBLTDev: Phillip Connaughton, RunKepper e-Legion
 
MBLT15: Vladimir Ena, Spotty
MBLT15: Vladimir Ena, SpottyMBLT15: Vladimir Ena, Spotty
MBLT15: Vladimir Ena, Spottye-Legion
 
MBLTDev15: Svetlana Sonina, STS Media
MBLTDev15: Svetlana Sonina, STS MediaMBLTDev15: Svetlana Sonina, STS Media
MBLTDev15: Svetlana Sonina, STS Mediae-Legion
 
MBLTDev15: Hector Zarate, Spotify
MBLTDev15: Hector Zarate, SpotifyMBLTDev15: Hector Zarate, Spotify
MBLTDev15: Hector Zarate, Spotifye-Legion
 
MBLT16: Dmitriy Geranin, Afisha Restorany
MBLT16: Dmitriy Geranin, Afisha RestoranyMBLT16: Dmitriy Geranin, Afisha Restorany
MBLT16: Dmitriy Geranin, Afisha Restoranye-Legion
 
MBLTDev15: Brigit Lyons, Soundcloud
MBLTDev15: Brigit Lyons, SoundcloudMBLTDev15: Brigit Lyons, Soundcloud
MBLTDev15: Brigit Lyons, Soundcloude-Legion
 
MBLTDev15: Artemiy Sobolev, Parallels
MBLTDev15: Artemiy Sobolev, ParallelsMBLTDev15: Artemiy Sobolev, Parallels
MBLTDev15: Artemiy Sobolev, Parallelse-Legion
 
MBLT15: Shahar Waiser, Gett
MBLT15: Shahar Waiser, GettMBLT15: Shahar Waiser, Gett
MBLT15: Shahar Waiser, Gette-Legion
 
MBLTDev15: Alexander Orlov, Postforpost
MBLTDev15: Alexander Orlov, PostforpostMBLTDev15: Alexander Orlov, Postforpost
MBLTDev15: Alexander Orlov, Postforposte-Legion
 
MBLTDev15: Cesar Valiente, Wunderlist
MBLTDev15: Cesar Valiente, WunderlistMBLTDev15: Cesar Valiente, Wunderlist
MBLTDev15: Cesar Valiente, Wunderliste-Legion
 
MBLT16: Marvin Liao, 500Startups
MBLT16: Marvin Liao, 500StartupsMBLT16: Marvin Liao, 500Startups
MBLT16: Marvin Liao, 500Startupse-Legion
 
MBLTDev: Alexander Dimchenko, Bright Box
MBLTDev: Alexander Dimchenko, Bright Box MBLTDev: Alexander Dimchenko, Bright Box
MBLTDev: Alexander Dimchenko, Bright Box e-Legion
 
MBLT16: Vincent Wu, Alibaba Mobile
MBLT16: Vincent Wu, Alibaba MobileMBLT16: Vincent Wu, Alibaba Mobile
MBLT16: Vincent Wu, Alibaba Mobilee-Legion
 
MBLT16: Alexander Lukin, AppMetrica
MBLT16: Alexander Lukin, AppMetricaMBLT16: Alexander Lukin, AppMetrica
MBLT16: Alexander Lukin, AppMetricae-Legion
 
MBLTDev15: Konstantin Goldshtein, Microsoft
MBLTDev15: Konstantin Goldshtein, MicrosoftMBLTDev15: Konstantin Goldshtein, Microsoft
MBLTDev15: Konstantin Goldshtein, Microsofte-Legion
 

Viewers also liked (20)

MBLT15: Alexey Chikov, Kaspersky Lab
MBLT15: Alexey Chikov, Kaspersky LabMBLT15: Alexey Chikov, Kaspersky Lab
MBLT15: Alexey Chikov, Kaspersky Lab
 
MBLTDev15: Sergey Semenov, Trucker Path
MBLTDev15: Sergey Semenov, Trucker Path MBLTDev15: Sergey Semenov, Trucker Path
MBLTDev15: Sergey Semenov, Trucker Path
 
MBLTDev15: Ivan Kozlov, Aviasales
MBLTDev15: Ivan Kozlov, AviasalesMBLTDev15: Ivan Kozlov, Aviasales
MBLTDev15: Ivan Kozlov, Aviasales
 
MBLT15: Ivan Kozlov, Aviasales
MBLT15: Ivan Kozlov, AviasalesMBLT15: Ivan Kozlov, Aviasales
MBLT15: Ivan Kozlov, Aviasales
 
MBLT15: Yakov Zubarev, Parallels
MBLT15: Yakov Zubarev, ParallelsMBLT15: Yakov Zubarev, Parallels
MBLT15: Yakov Zubarev, Parallels
 
MBLTDev: Phillip Connaughton, RunKepper
MBLTDev: Phillip Connaughton, RunKepper MBLTDev: Phillip Connaughton, RunKepper
MBLTDev: Phillip Connaughton, RunKepper
 
MBLT15: Vladimir Ena, Spotty
MBLT15: Vladimir Ena, SpottyMBLT15: Vladimir Ena, Spotty
MBLT15: Vladimir Ena, Spotty
 
MBLTDev15: Svetlana Sonina, STS Media
MBLTDev15: Svetlana Sonina, STS MediaMBLTDev15: Svetlana Sonina, STS Media
MBLTDev15: Svetlana Sonina, STS Media
 
MBLTDev15: Hector Zarate, Spotify
MBLTDev15: Hector Zarate, SpotifyMBLTDev15: Hector Zarate, Spotify
MBLTDev15: Hector Zarate, Spotify
 
MBLT16: Dmitriy Geranin, Afisha Restorany
MBLT16: Dmitriy Geranin, Afisha RestoranyMBLT16: Dmitriy Geranin, Afisha Restorany
MBLT16: Dmitriy Geranin, Afisha Restorany
 
MBLTDev15: Brigit Lyons, Soundcloud
MBLTDev15: Brigit Lyons, SoundcloudMBLTDev15: Brigit Lyons, Soundcloud
MBLTDev15: Brigit Lyons, Soundcloud
 
MBLTDev15: Artemiy Sobolev, Parallels
MBLTDev15: Artemiy Sobolev, ParallelsMBLTDev15: Artemiy Sobolev, Parallels
MBLTDev15: Artemiy Sobolev, Parallels
 
MBLT15: Shahar Waiser, Gett
MBLT15: Shahar Waiser, GettMBLT15: Shahar Waiser, Gett
MBLT15: Shahar Waiser, Gett
 
MBLTDev15: Alexander Orlov, Postforpost
MBLTDev15: Alexander Orlov, PostforpostMBLTDev15: Alexander Orlov, Postforpost
MBLTDev15: Alexander Orlov, Postforpost
 
MBLTDev15: Cesar Valiente, Wunderlist
MBLTDev15: Cesar Valiente, WunderlistMBLTDev15: Cesar Valiente, Wunderlist
MBLTDev15: Cesar Valiente, Wunderlist
 
MBLT16: Marvin Liao, 500Startups
MBLT16: Marvin Liao, 500StartupsMBLT16: Marvin Liao, 500Startups
MBLT16: Marvin Liao, 500Startups
 
MBLTDev: Alexander Dimchenko, Bright Box
MBLTDev: Alexander Dimchenko, Bright Box MBLTDev: Alexander Dimchenko, Bright Box
MBLTDev: Alexander Dimchenko, Bright Box
 
MBLT16: Vincent Wu, Alibaba Mobile
MBLT16: Vincent Wu, Alibaba MobileMBLT16: Vincent Wu, Alibaba Mobile
MBLT16: Vincent Wu, Alibaba Mobile
 
MBLT16: Alexander Lukin, AppMetrica
MBLT16: Alexander Lukin, AppMetricaMBLT16: Alexander Lukin, AppMetrica
MBLT16: Alexander Lukin, AppMetrica
 
MBLTDev15: Konstantin Goldshtein, Microsoft
MBLTDev15: Konstantin Goldshtein, MicrosoftMBLTDev15: Konstantin Goldshtein, Microsoft
MBLTDev15: Konstantin Goldshtein, Microsoft
 

Similar to MBLTDev15: Kyle Fuller, Apairy

Get up and running with google app engine in 60 minutes or less
Get up and running with google app engine in 60 minutes or lessGet up and running with google app engine in 60 minutes or less
Get up and running with google app engine in 60 minutes or lesszrok
 
Your Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckYour Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckAnthony Montalbano
 
Django Introduction Osscamp Delhi September 08 09 2007 Mir Nazim
Django Introduction Osscamp Delhi September 08 09 2007 Mir NazimDjango Introduction Osscamp Delhi September 08 09 2007 Mir Nazim
Django Introduction Osscamp Delhi September 08 09 2007 Mir NazimMir Nazim
 
Api's and ember js
Api's and ember jsApi's and ember js
Api's and ember jsEdwin Cruz
 
Rest experience-report
Rest experience-reportRest experience-report
Rest experience-reportJim Barritt
 
Compose Camp - Jetpack Compose for Android Developers _ Introduction Session ...
Compose Camp - Jetpack Compose for Android Developers _ Introduction Session ...Compose Camp - Jetpack Compose for Android Developers _ Introduction Session ...
Compose Camp - Jetpack Compose for Android Developers _ Introduction Session ...Svetlin Stanchev
 
Creating Chatbots with Botman - English
Creating Chatbots with Botman - EnglishCreating Chatbots with Botman - English
Creating Chatbots with Botman - EnglishLaravel Poland MeetUp
 
Laravel Poznań Meetup #2 - Creating chatbots with BotMan
Laravel Poznań Meetup #2 - Creating chatbots with BotManLaravel Poznań Meetup #2 - Creating chatbots with BotMan
Laravel Poznań Meetup #2 - Creating chatbots with BotManHighSolutions Sp. z o.o.
 
Html basics 10 form
Html basics 10 formHtml basics 10 form
Html basics 10 formH K
 
Connecting your Python App to OpenERP through OOOP
Connecting your Python App to OpenERP through OOOPConnecting your Python App to OpenERP through OOOP
Connecting your Python App to OpenERP through OOOPraimonesteve
 
Php forms and validations by naveen kumar veligeti
Php forms and validations by naveen kumar veligetiPhp forms and validations by naveen kumar veligeti
Php forms and validations by naveen kumar veligetiNaveen Kumar Veligeti
 
Working With Sharepoint 2013 Apps Development
Working With Sharepoint 2013 Apps DevelopmentWorking With Sharepoint 2013 Apps Development
Working With Sharepoint 2013 Apps DevelopmentPankaj Srivastava
 
Compose Camp - Jetpack Compose for Android Developers Introduction Session De...
Compose Camp - Jetpack Compose for Android Developers Introduction Session De...Compose Camp - Jetpack Compose for Android Developers Introduction Session De...
Compose Camp - Jetpack Compose for Android Developers Introduction Session De...JassGroup TICS
 
Designing web pages html forms and input
Designing web pages html  forms and inputDesigning web pages html  forms and input
Designing web pages html forms and inputJesus Obenita Jr.
 

Similar to MBLTDev15: Kyle Fuller, Apairy (20)

Get up and running with google app engine in 60 minutes or less
Get up and running with google app engine in 60 minutes or lessGet up and running with google app engine in 60 minutes or less
Get up and running with google app engine in 60 minutes or less
 
Your Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckYour Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages Suck
 
Django Introduction Osscamp Delhi September 08 09 2007 Mir Nazim
Django Introduction Osscamp Delhi September 08 09 2007 Mir NazimDjango Introduction Osscamp Delhi September 08 09 2007 Mir Nazim
Django Introduction Osscamp Delhi September 08 09 2007 Mir Nazim
 
Api's and ember js
Api's and ember jsApi's and ember js
Api's and ember js
 
Rest experience-report
Rest experience-reportRest experience-report
Rest experience-report
 
Compose Camp - Jetpack Compose for Android Developers _ Introduction Session ...
Compose Camp - Jetpack Compose for Android Developers _ Introduction Session ...Compose Camp - Jetpack Compose for Android Developers _ Introduction Session ...
Compose Camp - Jetpack Compose for Android Developers _ Introduction Session ...
 
Introduction html
Introduction htmlIntroduction html
Introduction html
 
Creating Chatbots with Botman - English
Creating Chatbots with Botman - EnglishCreating Chatbots with Botman - English
Creating Chatbots with Botman - English
 
Laravel Poznań Meetup #2 - Creating chatbots with BotMan
Laravel Poznań Meetup #2 - Creating chatbots with BotManLaravel Poznań Meetup #2 - Creating chatbots with BotMan
Laravel Poznań Meetup #2 - Creating chatbots with BotMan
 
SOLID Ruby, SOLID Rails
SOLID Ruby, SOLID RailsSOLID Ruby, SOLID Rails
SOLID Ruby, SOLID Rails
 
Html basics 10 form
Html basics 10 formHtml basics 10 form
Html basics 10 form
 
Connecting your Python App to OpenERP through OOOP
Connecting your Python App to OpenERP through OOOPConnecting your Python App to OpenERP through OOOP
Connecting your Python App to OpenERP through OOOP
 
Jetpack Compose Recap Session.pdf
Jetpack Compose Recap Session.pdfJetpack Compose Recap Session.pdf
Jetpack Compose Recap Session.pdf
 
Php forms and validations by naveen kumar veligeti
Php forms and validations by naveen kumar veligetiPhp forms and validations by naveen kumar veligeti
Php forms and validations by naveen kumar veligeti
 
Working With Sharepoint 2013 Apps Development
Working With Sharepoint 2013 Apps DevelopmentWorking With Sharepoint 2013 Apps Development
Working With Sharepoint 2013 Apps Development
 
CiviCRM API v3
CiviCRM API v3CiviCRM API v3
CiviCRM API v3
 
Compose Camp - Jetpack Compose for Android Developers Introduction Session De...
Compose Camp - Jetpack Compose for Android Developers Introduction Session De...Compose Camp - Jetpack Compose for Android Developers Introduction Session De...
Compose Camp - Jetpack Compose for Android Developers Introduction Session De...
 
Chapter 9: Forms
Chapter 9: FormsChapter 9: Forms
Chapter 9: Forms
 
Designing web pages html forms and input
Designing web pages html  forms and inputDesigning web pages html  forms and input
Designing web pages html forms and input
 
JMeter
JMeterJMeter
JMeter
 

More from e-Legion

MBLT16: Elena Rydkina, Pure
MBLT16: Elena Rydkina, PureMBLT16: Elena Rydkina, Pure
MBLT16: Elena Rydkina, Puree-Legion
 
MBLT16: Andrey Bakalenko, Sberbank Online
MBLT16: Andrey Bakalenko, Sberbank OnlineMBLT16: Andrey Bakalenko, Sberbank Online
MBLT16: Andrey Bakalenko, Sberbank Onlinee-Legion
 
Rx Java architecture
Rx Java architectureRx Java architecture
Rx Java architecturee-Legion
 
MBLTDev15: Egor Tolstoy, Rambler&Co
MBLTDev15: Egor Tolstoy, Rambler&CoMBLTDev15: Egor Tolstoy, Rambler&Co
MBLTDev15: Egor Tolstoy, Rambler&Coe-Legion
 
MBLTDev15: Alexander Dimchenko, DIT
MBLTDev15: Alexander Dimchenko, DITMBLTDev15: Alexander Dimchenko, DIT
MBLTDev15: Alexander Dimchenko, DITe-Legion
 
MBLTDev: Evgeny Lisovsky, Litres
MBLTDev: Evgeny Lisovsky, LitresMBLTDev: Evgeny Lisovsky, Litres
MBLTDev: Evgeny Lisovsky, Litrese-Legion
 
MBLTDev15: Anna Mikhina, Maxim Evdokimov, Tinkoff Bank
MBLTDev15: Anna Mikhina, Maxim Evdokimov, Tinkoff Bank MBLTDev15: Anna Mikhina, Maxim Evdokimov, Tinkoff Bank
MBLTDev15: Anna Mikhina, Maxim Evdokimov, Tinkoff Bank e-Legion
 
MBLTDev15: Ilya Krasilshchik, Meduza.io
MBLTDev15: Ilya Krasilshchik, Meduza.ioMBLTDev15: Ilya Krasilshchik, Meduza.io
MBLTDev15: Ilya Krasilshchik, Meduza.ioe-Legion
 
MBLTDev15: Marius Racwitz, Realm
MBLTDev15: Marius Racwitz, RealmMBLTDev15: Marius Racwitz, Realm
MBLTDev15: Marius Racwitz, Realme-Legion
 

More from e-Legion (9)

MBLT16: Elena Rydkina, Pure
MBLT16: Elena Rydkina, PureMBLT16: Elena Rydkina, Pure
MBLT16: Elena Rydkina, Pure
 
MBLT16: Andrey Bakalenko, Sberbank Online
MBLT16: Andrey Bakalenko, Sberbank OnlineMBLT16: Andrey Bakalenko, Sberbank Online
MBLT16: Andrey Bakalenko, Sberbank Online
 
Rx Java architecture
Rx Java architectureRx Java architecture
Rx Java architecture
 
MBLTDev15: Egor Tolstoy, Rambler&Co
MBLTDev15: Egor Tolstoy, Rambler&CoMBLTDev15: Egor Tolstoy, Rambler&Co
MBLTDev15: Egor Tolstoy, Rambler&Co
 
MBLTDev15: Alexander Dimchenko, DIT
MBLTDev15: Alexander Dimchenko, DITMBLTDev15: Alexander Dimchenko, DIT
MBLTDev15: Alexander Dimchenko, DIT
 
MBLTDev: Evgeny Lisovsky, Litres
MBLTDev: Evgeny Lisovsky, LitresMBLTDev: Evgeny Lisovsky, Litres
MBLTDev: Evgeny Lisovsky, Litres
 
MBLTDev15: Anna Mikhina, Maxim Evdokimov, Tinkoff Bank
MBLTDev15: Anna Mikhina, Maxim Evdokimov, Tinkoff Bank MBLTDev15: Anna Mikhina, Maxim Evdokimov, Tinkoff Bank
MBLTDev15: Anna Mikhina, Maxim Evdokimov, Tinkoff Bank
 
MBLTDev15: Ilya Krasilshchik, Meduza.io
MBLTDev15: Ilya Krasilshchik, Meduza.ioMBLTDev15: Ilya Krasilshchik, Meduza.io
MBLTDev15: Ilya Krasilshchik, Meduza.io
 
MBLTDev15: Marius Racwitz, Realm
MBLTDev15: Marius Racwitz, RealmMBLTDev15: Marius Racwitz, Realm
MBLTDev15: Marius Racwitz, Realm
 

MBLTDev15: Kyle Fuller, Apairy