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

BFFs For Swift

C8678b78a2c1c113302ce686f13435d1?s=47 Tim
February 03, 2020

BFFs For Swift

Many modern apps need to make 10s or even 100s or network calls just to populate the home screen. And they'll likely be calling multiple different APIs, all requiring different authentication methods, JSON parsing and aggregation. Not only does this increase battery drain and frustration for users on slow and unreliable networks, it places a huge burden on the developer that isn't easy to update or iterate on quickly.

In this talk we'll look at the Backend for Frontend pattern and see how we can leverage Swift in both our iOS applications and server applications to share code and make development faster. We'll show clear examples of how BFFs can dramatically simplify your networking code and how a BFF in Swift can help you develop iOS applications quicker by reducing context switching and being able to share code.

C8678b78a2c1c113302ce686f13435d1?s=128

Tim

February 03, 2020
Tweet

Other Decks in Programming

Transcript

  1. BFFs For Swift Tim Condon @0xTim

  2. BFFs For Swift @0xTim The Backend Problem General Purpose API

    Web Client
  3. BFFs For Swift @0xTim The Backend Problem General Purpose API

    Web Client iOS App Android App
  4. BFFs For Swift @0xTim The Backend Problem General Purpose API

    Web Client iOS App Android App Mobile Web Client TV Client
  5. BFFs For Swift @0xTim The Backend Problem General Purpose API

    Web Client iOS App Android App Mobile Web Client 3rd Party Service 3rd Party Service TV Client
  6. None
  7. BFFs For Swift @0xTim The Backend Problem iOS App Monolith

  8. BFFs For Swift @0xTim The Backend Problem iOS App Monolith

    Microservice
  9. BFFs For Swift @0xTim The Backend Problem iOS App Microservice

    Microservice Microservice Microservice Microservice
  10. BFFs For Swift @0xTim The Backend Problem iOS App Microservice

    Google API AWS API Microservice Microservice Microservice Microservice
  11. None
  12. BFFs For Swift @0xTim The Homescreen Problem Events Location Schedule

    Speakers
  13. BFFs For Swift @0xTim The Homescreen Problem Events Location Schedule

    Speakers GET /api/events/coming-up { "page": { "totalPages": 11, "nextPage": "/api/events/coming-up?page=2&count=100" }, "events": [ { "id": "5212187e-e431-46eb-aebd-be0fccd9a2fb", "name": "dotSwift", "start": "2020-02-03T09:30:00+01:00", "end": "2020-02-03T18:30:00+01:00", "speakers": [ "e6adf697-4c6b-48e8-b5c0-27a0b305ce09", ... "fb9989a4-97b3-472e-93b5-efaf8d207dfe" ], "emcee": "9ef5e988-18cd-438b-a61b-7334986c67ec", "location": { "latitude": 48.878765, "longitude": 2.330944, "id": "a1a02cd0-2a94-425d-bd04-c2d054ce254a" } } ], ... }
  14. BFFs For Swift @0xTim The Homescreen Problem Events Location Schedule

    Speakers GET /api/locations/a1a02cd0-2a94-425d-bd04-c2d054ce254a { "latitude": 48.878765, "longitude" 2.330944, "name": "Théâtre de Paris", "address": "15 Rue Blanche, 75009 Paris", "nearest-stations": [ { "line": "Green 12", "name": "Trinité" }, ... ] ... }
  15. BFFs For Swift @0xTim The Homescreen Problem Events Location Schedule

    Speakers GET /api/events/5212187e-e431-46eb-aebd-be0fccd9a2fb/schedule { "talks": [ ... { "title": "BFFs For Swift", "speaker": "e6adf697-4c6b-48e8-b5c0-27a0b305ce09", "start-time": "2020-02-03T14:30:00+01:00", "end-time": "2020-02-03T14:50:00+01:00", "room": "f5536b5a-223b-4a1a-b050-836bd4e924fa" }, { "title": "Property Wrappers or How Swift decided to become Java", "speaker": "fb9989a4-97b3-472e-93b5-efaf8d207dfe", "start-time": "2020-02-03T15:30:00+01:00", "end-time": "2020-02-03T15:50:00+01:00", "room": "9a1a7f2d-230e-40e0-8757-dc80ec4aa25d" }, ... ], "breaks": { ... } }
  16. BFFs For Swift @0xTim The Homescreen Problem Events Location Schedule

    Speakers GET /api/speakers/e6adf697-4c6b-48e8-b5c0-27a0b305ce09/ { "name": "Tim Condon", "profile-image": "https://s3-eu-central-1.amazonaws.com/ static-dotconferences-com/speakers_images/tim-condon.png", "talk": "c3d5735e-f8a3-4ca4-94c7-802c8f4306db", "bio": "Tim is the server-side Swift team lead at raywenderlich.com and has written the unofficial-official book on Vapor with the founders of the framework. He founded Broken Hands and delivers talks and workshops on Vapor and server-side Swift around the world. He also co-organises the ServerSide.swift conference.", "github": "0xTim", "twitter": "0xTim" }
  17. BFFs For Swift @0xTim The Homescreen Problem Events Location Schedule

    Speakers GET /api/events/coming-up { "page": { "totalPages": 11, "nextPage": "/api/events/coming-up?page=2&count=10" }, "events": [ { "name": "dotSwift", "date": "2020-02-03T00:00:00+01:00", "location": { "name": "Théâtre de Paris", "address": "15 Rue Blanche, 75009 Paris", }, "onNow": { "title": "BFFs For Swift", "startTime": "2020-02-03T14:30:00+01:00", "endTime": "2020-02-03T14:50:00+01:00", "speakerName": "Tim Condon" } } ], ... }
  18. BFFs For Swift @0xTim The Homescreen Problem Events Location Schedule

    Speakers
  19. BFFs For Swift @0xTim The Homescreen Problem Events Location Schedule

    Speakers iOS Team API Team
  20. None
  21. BFFs For Swift @0xTim The Homescreen Problem Events Location Schedule

    Speakers
  22. None
  23. Backend For Frontend

  24. BFFs For Swift @0xTim BFFs To The Rescue iOS App

    General Purpose API Weather API AWS Microservice Microservice
  25. BFFs For Swift @0xTim BFF BFFs To The Rescue iOS

    App General Purpose API Weather API AWS Microservice Microservice
  26. BFFs For Swift @0xTim BFFs To The Rescue BFF iOS

    App GET /api/events/coming-up { "page": { "totalPages": 11, "nextPage": "/api/events/coming-up?page=2&count=10" }, "events": [ { "name": "dotSwift", "date": "2020-02-03T00:00:00+01:00", "location": { "name": "Théâtre de Paris", "address": "15 Rue Blanche, 75009 Paris", }, "onNow": { "title": "BFFs For Swift", "startTime": "2020-02-03T14:30:00+01:00", "endTime": "2020-02-03T14:50:00+01:00", "speakerName": "Tim Condon" } } ], ... }
  27. BFFs For Swift @0xTim BFF Ownership iOS App AWS API

    iOS BFF Microservice Microservice Microservice Android BFF Web BFF Android App Website Client
  28. BFFs For Swift @0xTim BFF Ownership iOS App AWS API

    iOS BFF Microservice Microservice Microservice Android BFF Web BFF Android App Website Client API Team iOS Team Android Team Web Team
  29. – Sam Newman, Thoughtworks “The BFF is tightly coupled to

    a specific user experience, and will typically be maintained by the same team as the user interface, thereby making it easier to define and adapt the API as the UI requires, while also simplifying process of lining up release of both the client and server components.”
  30. BFFs For Swift @0xTim BFF Examples

  31. BFFs in Swift

  32. BFFs For Swift @0xTim Swift on the Server

  33. BFFs For Swift @0xTim Is it ready for production?

  34. None
  35. BFFs For Swift @0xTim Swift in BFFs

  36. BFFs For Swift @0xTim Sharing Code

  37. BFFs For Swift @0xTim Sharing Code BFF Models Package BFF

  38. BFFs For Swift @0xTim GET /api/events/coming-up { "page": { "totalPages":

    11, "nextPage": "/api/events/coming-up?page=2&count=10" }, "events": [ { "name": "dotSwift", "date": "2020-02-03T00:00:00+01:00", "location": { "name": "Théâtre de Paris", "address": "15 Rue Blanche, 75009 Paris", }, "on-now": { “title": "BFFs For Swift", "startTime": "2020-02-03T14:30:00+01:00", "endTime": "2020-02-03T14:50:00+01:00", "speakerName": "Tim Condon" } } ], ... } struct ComingUpResponse: Codable { let page: PaginationInformation let events: [ComingUpEvent] } struct PaginationInformation: Codable { let totalPages: Int let nextPage: URL } Sharing Code
  39. BFFs For Swift @0xTim Sharing Code GET /api/events/coming-up { "page":

    { "totalPages": 11, "nextPage": "/api/events/coming-up?page=2&count=10" }, "events": [ { "name": "dotSwift", "date": "2020-02-03T00:00:00+01:00", "location": { "name": "Théâtre de Paris", "address": "15 Rue Blanche, 75009 Paris", }, "on-now": { “title": "BFFs For Swift", "startTime": "2020-02-03T14:30:00+01:00", "endTime": "2020-02-03T14:50:00+01:00", "speakerName": "Tim Condon" } } ], ... } struct ComingUpEvent: Codable { let name: String let date: Date let location: ComingUpLocation let onNowInfo: ComingUpOnNowInfo } struct ComingUpLocation: Codable { let name: String let address: String } struct ComingUpOnNowInfo: Codable { let title: String let startTime: Date let endTime: Date let speakerName: String }
  40. BFFs For Swift

  41. Thank you! @0xTim