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

Onion-like app architecture

Onion-like app architecture

Learn how to architect an entire app – from UI, through user / data flows and transactions down to data storage and delivery – in independent, interchangeable layers. With layers that can be freely combined as needed, with no or minimal disruption to the rest of app. Just like an onion. You will learn that MVC is excellent, if employed properly. You will learn how to use Coordinators without delegates and with truly minimal UIKit extensions. Learn about an approach suitable for iOS teams of one and teams of 1000 developers. For 5 screen apps and for 200+ UIViewController behemots.

https://github.com/radianttap/Coordinator

https://github.com/radianttap/Spotifier

Video: https://www.youtube.com/watch?v=kD8dRvEQ5II

More Decks by Aleksandar Vacić (Radiant Tap)

Other Decks in Technology

Transcript

  1. Aleksandar Vacić
    @radiantav
    O N I O N - L I K E A P P A R C H I T E C T U R E
    App Builders 2019

    View Slide

  2. Aleksandar Vacić
    Belgrade, Serbia
    radianttap.com
    aplus.rs
    @radiantav

    View Slide

  3. Why architecture?
    architecture?

    View Slide

  4. HomeController
    ProductDetailsController
    ProductsController

    View Slide

  5. View Slide

  6. Architecture of complex apps
    is ever evolving, quite often
    in unforseen ways.

    View Slide

  7. View Slide

  8. Fashion SPORTS BETTING Sales

    View Slide

  9. · 100+ screens (few dozen are multi-screen flows)
    · multiple external services
    · 10+ languages (with runtime updates)
    · 20+ markets in Europe, Africa and S. America
    · iOS, tvOS, watchOS, widgets
    · Notifications, deep links, home screen actions
    SPORTS BETTING
    · Unpredictable future expansion

    View Slide

  10. Connect to web services
    Import into local storage
    Cache temporary data
    Directly target any screen, at any depth
    Transform any 3rd party data model into my own
    Multi-screen user flow
    Multi-service data flow
    Multi-OS reusability
    Reading data is always super performant
    c h a l l e n g e s

    View Slide

  11. Build complex system that works
    by first building a simple system
    that works.
    Break complex, multi-faceted flows
    into self-sufficient steps.
    Then compose them back.
    p r i n c i p l e s

    View Slide

  12. DATA MODEL

    View Slide

  13. Data Source
    Data Delivery
    Data Storage
    DATA MODEL

    View Slide

  14. Data Source
    Data Delivery
    Data Storage
    web service, bundled file,
    cached download
    URLSession, FileManager,
    Authentication, Encryption
    Core Data, mobile db,
    in-memory, file / custom store

    View Slide

  15. Data
    UI

    View Slide

  16. Data
    UI

    View Slide

  17. Data
    UI

    View Slide

  18. View Slide

  19. Data
    UI

    View Slide

  20. Data
    UI

    View Slide

  21. Data
    UI

    View Slide

  22. UI
    Data

    View Slide

  23. UI
    Data

    View Slide

  24. Data
    UI
    UI Coordinators

    View Slide

  25. UI
    UI Coordinators
    Data

    View Slide

  26. UI
    UI Coordinators
    Middleware
    Data

    View Slide

  27. Data Source
    Data Delivery
    Data Storage
    UI
    UI Coordinators
    Middleware
    L A Y E R S
    DATA MODEL

    View Slide

  28. O N I O N
    It resembles , isn’t it?

    View Slide

  29. O N I O N
    G A R L I C
    It resembles , isn’t it?

    View Slide

  30. Data Source
    Data Delivery
    Data Storage
    UI
    UI Coordinators
    Middleware
    L A Y E R E D
    DATA MODEL
    KEEP IT
    & SIMPLE

    View Slide

  31. Coordinator

    Advanced implementation of said pattern in
    Swift, including care-free messaging through
    UIResponder chain.
    Avenue

    URLSession wrapper, handles boilerplate,
    enables seamless usage with
    Operation(Queue).
    Ambar

    Custom Core Data stack with automatic merge
    of background imports into main MOC.
    / radianttap

    View Slide

  32. DEMO
    radianttap
    / Spotifier
    /

    View Slide

  33. What were my problems, or…
    KILS Architecture Benefits
    Builds on system frameworks
    ɠ
    Rapid iterations
    ɡ
    Painless refactoring
    ɢ
    Low maintenance cost
    ɣ

    View Slide

  34. / radianttap
    SpeakerDeck.com / radianttap
    aplus.rs
    Aleksandar Vacić, radianttap.com
    @radiantav
    SLIDES
    DEV BLOG
    CONTACT

    View Slide