Android VIPER Architecture implementation

5fe26dafd08dacd25664e885604cbc4f?s=47 Jiri Helmich
November 24, 2016

Android VIPER Architecture implementation

How to implement VIPER aka Clean Architecture on Android

5fe26dafd08dacd25664e885604cbc4f?s=128

Jiri Helmich

November 24, 2016
Tweet

Transcript

  1. 3.
  2. 4.

    VIEW Should take care of following: • UI rendering •

    UI components • Data displaying • Should wrap main View objects and provide them to lower levels • Android API specific stuff which does require Activity Context
  3. 5.

    PRESENTER This layer should behave like a bridge between UI

    and it’s data. It should: • Handle UI events • Update UI based on events • Communicate with ViewModel to update / gather data • Should use Data Binding framework
  4. 6.

    VIEWMODEL This layer should hold View state and data. It

    should take care of: • View state operations • Persist over UI configuration changes • View related data operations • Should use Observer pattern to notify changes
  5. 7.

    INTERACTOR This layer should operate with all the business logic

    data necessary for the ViewModel and should push them there. Should take care of: • Data operation to / from various data sources • ViewModel-ready data preparation
  6. 9.

    ROUTER Basically an utilized class to handle screen related navigation.

    Therefore any Fragment or Activity starting / showing / hiding operations. Similar to Navigator pattern.
  7. 10.
  8. 11.

    MOTIVATION Why should I choose VIPER architecture for my project?

    • Good modularization • Concern separation • SOLID principles • Clean to read and understand • High testing ability (good for TDD)
  9. 12.

    “It is not enough for code to work.“ ROBERT C.

    MARTIN, Clean Code: A Handbook of Agile Software Craftsmanship
  10. 14.

    Differences against MVVM • More abstraction • Best for more

    complex projects • Overkill for simple applications • More layers thus better concern separation • Better testability
  11. 15.

    TIME COMPLEXITY - It is really complex to implement it.

    - You should be patient and careful when building the base. - If you are going for a huge project. => Don’t reinvent the wheel. http://www.memes.com/img/635087
  12. 16.
  13. 17.
  14. 23.