Effective Android Architecture - MWDC

B1b15a8df73879b1d5eb247fee2028eb?s=47 Richa
July 16, 2015

Effective Android Architecture - MWDC

Yet another talk on Android architecture at MWDC 2015

B1b15a8df73879b1d5eb247fee2028eb?s=128

Richa

July 16, 2015
Tweet

Transcript

  1. 4.
  2. 5.
  3. 6.
  4. 7.
  5. 8.
  6. 10.

    MVC

  7. 12.

    MODEL VIEW CONTROLLER Interact with DB Render Model Handle view

    events Update model Invoke next UI Table of Responsibilities
  8. 14.
  9. 15.

    MODEL VIEW CONTROLLER Interact with DB Render Model Handle view

    events Interact with network Manage view state Update model Navigation Interact with system components Handle system events Update view on system events
  10. 16.

    Model public class CourseModel { Course getFromDatabase() { // fetch

    from db, or local cache } Course getFromNetwork() { // fetch from apis, cache when possible } }
  11. 18.

    Controller void onClick() {} void onModelUpdated() {} void onNewNotification() {}

    void onLocationUpdated(Location loc) {} void takePhoto(Activity context) {} void launchView(Activity context ) {}
  12. 19.
  13. 20.
  14. 21.
  15. 22.

    MODEL VIEW CONTROLLER Interact with DB Render Model Handle view

    events Interact with network Manage view state Update model Navigation Interact with system components Handle system events Update view on system events
  16. 25.

    MODEL VIEW CONTROLLER INTERACTOR Retrieve data from DB Render Model

    Handle view events Interact with external entities Retrieve data from network Manage view state Navigation Forward system events to view Forward model updates to view
  17. 28.

    MODEL VIEW CONTROLLER INTERACTOR VIEW MODEL Retrieve data from Network

    Render View Model Handle view events Interact with external entities View state / behavior Retrieve data from network Navigation Update view state
  18. 30.

    MODEL VIEW PRESENTER INTERACTOR VIEW MODEL Retrieve data from DB

    Render View Model Handle view events Interact with external entities View state / behavior Retrieve data from network Navigation Update view state
  19. 32.

    ENTITIES VIEW PRESENTER INTERACTOR VIEW MODEL Get data from Data

    Sources Render View Model Handle view events Interact with external entities View state / behavior Navigation Update view state
  20. 35.

    ENTITIES VIEW PRESENTER INTERACTOR VIEW MODEL FLOW CONTROLLER Get data

    from Data Sources Render View Model Handle view events Update view state Interact with external entities View state / behavior Navigation
  21. 36.
  22. 38.
  23. 39.
  24. 40.
  25. 41.

    S ingle Responsibility Principle O pen/Closed Principle L iskov Substitution

    Principle I nterface Segregation Principle D ependency Inversion Principle
  26. 43.
  27. 45.

    Activity Video Module Activity Quiz Module Navigation Main Activity Shell

    App Catalog Activity Catalog Module url Intent Intent Register with url Modules
  28. 46.

    Deep links Shell App Video Activity Video Module Catalog Activity

    Catalog Module register register url Intent Intent
  29. 49.
  30. 50.
  31. 51.

    Dealing with context Presenter(Context context) Interactor(Context context) NetworkClient(Context context) PersistenceClient(Context

    context) context.getSystemService(“SERVICE”) context.startActivity(intent) context.startActivityForResult(intent)
  32. 57.
  33. 70.

    CatalogViewModel public final BehaviorSubject<Catalog> catalog = BehaviorSubject.create(); public void subscribeToCatalog(Action1

    action) { catalog.subscribe(action); } public void unsubscribeToCatalog() { catalog.unsubscribe(); }
  34. 71.

    CatalogInteractor Context mContext; public CatalogInteractor(Context context) { mContext = context;

    } public Observable loadCatalog() { return catalogDataSource.loadCatalog(); }
  35. 72.
  36. 73.