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

Android Architectures

Android Architectures

Brief introduction about widely used android architectures, their advantages and drawbacks.

Darshan Parikh

March 26, 2017
Tweet

More Decks by Darshan Parikh

Other Decks in Programming

Transcript

  1. Goal! • Scalable (Large scale vision / new features) •

    Maintenance (Anyone can be able to understand and edit it) • Testing (easily testable)
  2. Pros: • Preferable for small apps Cons: • Activities and

    Fragments get bigger and bigger • Hard to understand for other developers • Unit testing is impossible • Implementing new feature takes lot of time Classic Android
  3. Model View Controller (MVC) Model: • POJO classes • Business

    logic View: • Layout resources Controller: • Activity • Fragments • Adapters
  4. Pros: • UI and business logic is not connected •

    Easier to unit test Cons: • Huge controllers • Violates Single Responsibility principles • Man in the middle (Controller) Model View Controller (MVC)
  5. Model View Presenter (MVP) View: • Renders logic Presenter: •

    Handle User events and callbacks Model: • Database logic • REST Helpers
  6. Pros: • Huge tasks split into simpler tasks • Smaller

    objects, less bugs • Easy to unit test Cons: • Model can’t be reused, tied to specific user case • Presenter mainly does the invoking and callback stuff Model View Presenter (MVP)
  7. Pros: • Independent of Frameworks • Independent of UI •

    Independent of Java • Independent of Database Cons: • Lots of layers Clean Architecture
  8. Model View ViewModel (MVVM) View: • Activity Model: • POJO

    classes ViewModel: • Interaction with model • Updating the View
  9. Model View ViewModel (MVVM) • Microsoft pattern • Removes UI

    code from Activities / Fragments • Binding ViewModels to UI (Using databinding) • Easy unit tests • No ‘findViewById()’...............
  10. XML Code sample <layout ...> <data> <variable .... /> </data>

    <TextView ...... android:visibility=”@{viewModel.hasValue ? View.VISIBLE : View.GONE}”> </TextView> </layout> GitHub sample: https://github.com/activesince93/MVVMDemo