Upgrade to Pro — share decks privately, control downloads, hide ads and more …

V for Versioning - RubyConf ID 2017

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

V for Versioning - RubyConf ID 2017

API versioning is a simple yet sensitive issue. Doing it wrong, you'll certainly see a cold war between API and mobile app devs, not to mention angry clients with their unusable app because of API-incompatibility issue. This talk will show how to handle API versioning with care and prevent a war :)

Avatar for Harwin Prahara

Harwin Prahara

October 06, 2017
Tweet

More Decks by Harwin Prahara

Other Decks in Programming

Transcript

  1. About Me Alumnus of - Bachelor, Computer Science 2008 -

    2012 - Master Program, Information Technology 2015-2017
  2. Disclaimer - The story on this talk is about fictional

    company, called CabePedas (hot chilli ) - The story, company, all names, characters, and incidents portrayed in this talk are fictitious. No identification with actual persons (living or deceased), places, buildings, and products is intended or should be inferred.
  3. About CabePedas - Global public tech company - More than

    80 global software engineers - Offices: Tokyo #, Bristol$, Jakarta%, Beirut&, Alicante ', and some other global cities
  4. What is API? “a set of rules that allows programmers

    to develop software for a particular operating system without having to be completely familiar with that operating system” Merriam webster dictionary
 https://www.merriam-webster.com/dictionary/application%20programming%20interface
  5. What is API? “a set of rules that allows programmers

    to develop software for a particular operating system without having to be completely familiar with that operating system” Merriam webster dictionary
 https://www.merriam-webster.com/dictionary/application%20programming%20interface
  6. What is API? - API provides a bridge that connects

    Rails developer and Android / iOS developer - There are various API format, 2 commonly used ones are: JSON and XML
  7. API - common format - JSON { "recipe":{ "id" :

    171006, "title" : "Sate Ayam", "story" : "Kami mengadakan pesta sate hari ini", "serving" : "4 piring", "cooking_time" : "40 menit", "created_at" : "2017-10-06T14:50:00Z", "updated_at" : "2017-10-07T15:20:00Z", "href" : "http://****/recipes/171006-Sate-Ayam" } }
  8. API - common format - XML <?xml version="1.0" encoding="UTF-8" ?>

    <recipe> <id>171006</id> <title>Sate Ayam</title> <story>Kami mengadakan pesta sate hari ini</story> <serving>4 piring</serving> <cooking_time>40 menit</cooking_time> <created_at>2017-10-06T14:50:00Z</created_at> <updated_at>2017-10-07T15:20:00Z</updated_at> <href>http://****/recipes/171006-Sate-Ayam</href> </recipe>
  9. CabePedas Sample JSON { "recipe":{ "id" : 171006, "title" :

    "Sate Ayam", "story" : "Kami mengadakan pesta sate hari ini", "serving" : "4 piring", "cooking_time" : "40 menit", "created_at" : "2017-10-06T14:50:00Z", "updated_at" : "2017-10-07T15:20:00Z", "href" : "http://****/recipes/171006-Sate-Ayam"
 ... } }
  10. CabePedas API in Action - 3 { "recipe":{ "id" :

    171006, "title" : "Sate Ayam", "story" : "Kami mengadakan pesta sate hari ini", "serving" : "4 piring", "cooking_time" : "40 menit", "created_at" : "2017-10-06T14:50:00Z", "updated_at" : "2017-10-07T15:20:00Z", "href" : "http://****/recipes/171006-Sate-Ayam"
 ... } }
  11. CabePedas API in Action - 3 { "recipe":{ "id" :

    171006, "title" : "Sate Ayam", "story" : "Kami mengadakan pesta sate hari ini", "serving" : "4 piring", "cooking_time" : "40 menit", "created_at" : "2017-10-06T14:50:00Z", "updated_at" : "2017-10-07T15:20:00Z", "href" : "http://****/recipes/171006-Sate-Ayam" ... } }
  12. CabePedas - Innovative Tech Company - Move fast, break things

    - Do not ask permission, ask forgiveness later
  13. CabePedas - Innovative Tech Company - Move fast, break things

    - Do not ask permission, ask forgiveness later - [Insert some other jargon here]
  14. CabePedas - Moving Too Fast - API dev team doing

    code-cleaning 
 (clean code movement ftw!)
  15. CabePedas - Moving Too Fast - API dev team doing

    code-cleaning 
 (clean code movement ftw!) - Some “dusty” endpoints are removed
  16. CabePedas - Moving Too Fast - API dev team doing

    code-cleaning 
 (clean code movement ftw!) - Some “dusty” endpoints are removed - Rolling out to users immediately 
 (cap production deploy ftw!)
  17. CabePedas - Moving Too Fast - API dev team doing

    code-cleaning 
 (clean code movement ftw!) - Some “dusty” endpoints are removed - Rolling out to users immediately 
 (cap production deploy ftw!)
  18. CabePedas - Moving Too Fast Dude, CabePedas apps are unusable.

    Users are flocking our main entrance, they’re burning tires!
  19. CabePedas - Moving Too Fast Not for newest app version,

    but we’re still rolling it out, most users have not updated yet!
  20. CabePedas - Restropective - Mobile apps and API server have

    different roll out nature - Rolling out changes on server side will instantly take effect for all users - Rolling out new version of apps will only affect users who updates 
 (it takes some time for most users to update)
  21. CabePedas - Restropective - Mobile apps and API server have

    different roll out nature - Rolling out changes on server side will instantly take effect for all users - Rolling out new version of apps will only affect users who updates 
 (it takes some time for most users to update) - This timing gap could cause
  22. CabePedas - Rule #1 If API change contains breaking changes..

    (Changes that will make previous app version ) Then… Bump API version Make sure next app version uses new endpoint
  23. CabePedas - Rule #2 You can’t support legacy app forever

    At some point, you’ll reach a cut-off point When that time comes, make sure your users know about it
  24. CabePedas - Rule #2 Example CabePedas app implements 
 a

    “please update” mechanism in-app
  25. CabePedas - Rule #2 Example When client hits an obsolete

    endpoint... API server will respond with 
 “hey, you’re trying to access obsolete endpoints”
  26. CabePedas - Rule #2 Example When client hits an obsolete

    endpoint... API server will respond with 
 “hey, you’re trying to access obsolete endpoints” Client will then show “please update” screen
  27. Rule of thumb #1 Bump API version, if there are

    breaking changes #2 Tell user nicely when their app is no longer supported