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 full-size slide

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

    View full-size slide

  3. Arch Patterns in Android
    3

    View full-size slide

  4. Architecture
    What is an Architecture
    4

    View full-size 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 full-size slide

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

    View full-size slide

  7. SOLID
    Principles
    7

    View full-size slide

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

    View full-size slide

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

    View full-size 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 full-size slide

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

    View full-size slide

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

    View full-size slide

  13. Layers
    In an usual Android App
    13

    View full-size slide

  14. data
    presentation
    ui
    domain (?)
    cache
    remote

    View full-size slide

  15. data
    presentation
    ui

    View full-size slide

  16. data
    16
    Repository
    LocalDataStore
    RemoteDataStore
    AppService / ApiService DB

    View full-size slide

  17. presentation & ui
    17
    MVP
    MVI
    MVVM
    MvRx
    mobius

    View full-size slide

  18. Architecture Patterns
    18

    View full-size slide

  19. MVP
    19
    View Interface
    Contract
    Presenter Interface
    tight coupling

    View full-size slide

  20. MVVM
    20
    ViewModel

    View full-size slide

  21. MVVM + State
    21
    ViewModel State

    View full-size slide

  22. MVI
    22
    ViewModel
    State
    Action
    Result
    Intent

    View full-size 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 full-size slide