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

Patterns for Offline-first applications

Patterns for Offline-first applications

The best applications function equally well with and without network access. Offline functionality
goes beyond a simple cache or database, and it is not a binary choice. Offline first encompasses
project requirements, user interface design, security and code architecture.

In this talk we'll review the challenges and ways to build applications that take offline as a first class requirement.

Miguel Angel Quinones Garcia

October 21, 2017
Tweet

More Decks by Miguel Angel Quinones Garcia

Other Decks in Programming

Transcript

  1. TOPICS > PROBLEM: NOT ALWAYS CONNECTED > DESIGNING FOR OFFLINE

    > DATA SYNCHRONIZATION > DATA-DRIVEN UI 3 — Miguel Angel Quinones - @miguelquinon - miqu.me
  2. TOPICS > PROBLEM: NOT ALWAYS CONNECTED > DESIGNING FOR OFFLINE

    > DATA SYNCHRONIZATION > DATA-DRIVEN UI 4 — Miguel Angel Quinones - @miguelquinon - miqu.me
  3. > Roaming abroad > In the wildlife > Tube >

    Night club > Event with many people > Travelling by plane or train 6 — Miguel Angel Quinones - @miguelquinon - miqu.me
  4. > Hospital workers > Construction site staff > Corporate salesmen

    > Oil rig crew 7 — Miguel Angel Quinones - @miguelquinon - miqu.me
  5. USE YOUR APP AS A USER. GO OUT OF THE

    OFFICE. 8 — Miguel Angel Quinones - @miguelquinon - miqu.me
  6. > Lie-Fi > AR/VR bandwidth requirements 1 > Network speeds

    getting slower! 1 https://medium.com/@sajuab/why-we-desperately-need-a-disruption-in-mobile-connectivity-33255052fcf5 9 — Miguel Angel Quinones - @miguelquinon - miqu.me
  7. TOPICS > PROBLEM: NOT ALWAYS CONNECTED > DESIGNING FOR OFFLINE

    > DATA SYNCHRONIZATION > DATA-DRIVEN UI 11 — Miguel Angel Quinones - @miguelquinon - miqu.me
  8. Q1: OFFLINE: WHAT DOES IT MEAN FOR MY APP? 12

    — Miguel Angel Quinones - @miguelquinon - miqu.me
  9. 1. NO NETWORK IS AN ERROR 13 — Miguel Angel

    Quinones - @miguelquinon - miqu.me
  10. OFFLINE USAGE: ERROR HANDLING > Graceful degradation > Optimistic UI

    17 — Miguel Angel Quinones - @miguelquinon - miqu.me
  11. GRACEFUL DEGRADATION OR HOW I DON'T WANT TO BE BLAMED

    FOR NOT HAVING NETWORK CONNECTION 18 — Miguel Angel Quinones - @miguelquinon - miqu.me
  12. OPTIMISTIC UI ERRORS > Salience > Casuality 20 — Miguel

    Angel Quinones - @miguelquinon - miqu.me
  13. TOPICS > PROBLEM: NOT ALWAYS CONNECTED > DESIGNING FOR OFFLINE

    > DATA SYNCHRONIZATION > DATA-DRIVEN UI 23 — Miguel Angel Quinones - @miguelquinon - miqu.me
  14. Don't Reinvent The Wheel, Unless You Plan on Learning More

    About Wheels — Jeff Atwood 24 — Miguel Angel Quinones - @miguelquinon - miqu.me
  15. ! SYNCHRONIZATION PROBLEM ! > Dependant on data > Data

    loss is critical > Merges > Conflicts 31 — Miguel Angel Quinones - @miguelquinon - miqu.me
  16. CONFLICT RESOLUTION > Latest wins > Server wins > User

    decides ⚠ > Conflict resolution: where > No conflict by design 33 — Miguel Angel Quinones - @miguelquinon - miqu.me
  17. ⚠ BEST PRACTICES ⚠ > ! Timestamps are unreliable >

    Use GUIDs > Deterministic conflict resolution > Don't delete > First pull, then push > Design for less conflicts 34 — Miguel Angel Quinones - @miguelquinon - miqu.me
  18. SYNC: THERE'S MORE! > Differential synchronization ** > Lamport timestamps,

    vector clocks > Conflict-free Replicated Data Types ** https://neil.fraser.name/writing/sync/ 35 — Miguel Angel Quinones - @miguelquinon - miqu.me
  19. SYNC: AVAILABLE WHEELS > CouchDB lite > Realm > Firebase

    36 — Miguel Angel Quinones - @miguelquinon - miqu.me
  20. TOPICS > PROBLEM: NOT ALWAYS CONNECTED > DESIGNING FOR OFFLINE

    > DATA SYNCHRONIZATION > DATA-DRIVEN UI 37 — Miguel Angel Quinones - @miguelquinon - miqu.me
  21. DATA-DRIVEN UI > Data can change anytime > UI listens

    to data changes > Reactive 39 — Miguel Angel Quinones - @miguelquinon - miqu.me
  22. CHANGE RECONCILIATION How to make users ! tableView.reloadData() 42 —

    Miguel Angel Quinones - @miguelquinon - miqu.me
  23. RECONCILIATION: WORD OF ⚠ > Naive LCS: O(N*M) > Myers

    diff: O((N+M)*D) > Paul Heckel's diff O(N) > Read the ! > http://wiki.c2.com/?DiffAlgorithm 45 — Miguel Angel Quinones - @miguelquinon - miqu.me
  24. DIFFING LIBRARIES > Dwifft (LCS) > Differ (Myers) > HeckelDiff

    (Heckel) > IGListKit (Heckel) 46 — Miguel Angel Quinones - @miguelquinon - miqu.me