...
- Create a contract (Java interace) that has for each concept and define interfaces for the view, model and presenter in the contract.
- The three components should implement interfaces from the contract created in rule 1 above.
- In each component, reference the interface of the other component rather than the implementation.
- Model should be referenced in the Presenter and not the View.
- View should not be referenced in the Model.
- Avoid android dependencies in the Presenter.
- Use an interactor to calls make calls to the database or network layer i i.e. using Async Tasks or Handlers.
- Interactor should sit between the Presenter and the model.
- Interactor should be initialized in the Presenter
- Have one contract for each concept that defines the interfaces for the view, presenter and model
- Start async tasks in the interactor
- .
- All database calls should be made using:
- Async tasks
- Future tasks (TODO find We need a way to move waiting of moving this from the main thread).
- Prester tests should mock the view and the interactor (If implemented).
- Model tests should mock the presenter.
We have created sample mvp applications that respect these rules in https://github.com/OpenSRP/opensrp-client-architecture/tree/mvp
Please check them out and if possible add your sample mvp application there.
Instrumentation Tests
References
https://developer.android.com/studio/test/
...