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

Arch Patterns in Android

Arch Patterns in Android

Presented online at GDG Kolkata (https://youtu.be/h6g0T7CQbcY).
This presentation talks about Architecture patterns in android, and how to migrate from MVP to MVVM etc.

Rivu Chakraborty

April 12, 2020
Tweet

More Decks by Rivu Chakraborty

Other Decks in Programming

Transcript

  1. Arch Patterns in Android
    GDG Kolkata
    Rivu Chakraborty
    https://www.rivu.dev
    1

    View Slide

  2. Rivu Chakraborty
    Sr. Software Engineer - BYJU’S
    https://rivu.dev
    Tech Author, Tech Speaker, Android Dev,
    Kotlin Advocate
    2

    View Slide

  3. Arch Patterns in Android
    3

    View Slide

  4. Architecture
    What is an Architecture
    4

    View Slide

  5. What’s an Architecture?
    An Architecture is a Code structure / collection of principles / patterns, that helps
    better organise code in a project for easy maintenance and future changes. It also
    enables you to have efficient test case coverages.
    5

    View Slide

  6. Architecture
    Where does it come from? What Patterns / Principles
    6

    View Slide

  7. SOLID
    Principles
    7

    View Slide

  8. Every class should have a Single
    Responsibility
    Single-Responsibility
    8

    View Slide

  9. Entities Should be Open for Extension,
    Closed for Modification
    Open-Closed
    9

    View Slide

  10. Let Φ(x) be a property provable about
    objects x of type T. Then Φ(y) should be true for
    objects y of type S where S is a subtype of T.
    Liskov Substitution
    10

    View Slide

  11. Clients should not be forced to depend upon
    interfaces that they do not use.
    Interface Segregation
    11

    View Slide

  12. A class that uses a dependency, shouldn’t
    create / know how to create that dependency
    Depencency Inversion (IoC)
    12

    View Slide

  13. Layers
    In an usual Android App
    13

    View Slide

  14. data
    presentation
    ui
    domain (?)
    cache
    remote

    View Slide

  15. data
    presentation
    ui

    View Slide

  16. data
    16
    Repository
    LocalDataStore
    RemoteDataStore
    AppService / ApiService DB

    View Slide

  17. presentation & ui
    17
    MVP
    MVI
    MVVM
    MvRx
    mobius

    View Slide

  18. Architecture Patterns
    18

    View Slide

  19. MVP
    19
    View Interface
    Contract
    Presenter Interface
    tight coupling

    View Slide

  20. MVVM
    20
    ViewModel

    View Slide

  21. MVVM + State
    21
    ViewModel State

    View Slide

  22. MVI
    22
    ViewModel
    State
    Action
    Result
    Intent

    View Slide

  23. Thank You
    23
    MVP: https://github.com/RivuChk/MovieSearchOMDBMVP
    MVVM: https://github.com/RivuChk/MovieSearchOMDBMVVM
    MVVM + State: https://github.com/RivuChk/MovieSearchOMDBMVVMState
    MVI: https://github.com/RivuChk/Android-MVI-Clean-Arch-Sample
    https://www.rivu.dev

    View Slide