I am trying to understand better MVP Architecture on Android.To do that, i want to implement MVP on android project from beginning.

First i tried to use one module, which is app(Application app),but my app started to grow a little fast than i expected.And testing takes way to much time to finish or i they give me an error and never pass. I think i made this version of app very tight coupled.

The next thing i tried to do is to use 3 Modules Projects.

--app (Application module)

--Domain layer

--Data layer

And started to read about to set up the dependency, and i think i hit a crossroad.

I understand that Domain layer, must be and should be independent.

So, the dependency should be like this App ----> depend on Domain Layer or Data Layer or both? Data layer ----> depend on Domain layer

1 Answer 1


First let's deal with the obvious parts of MVP:

  • The View is only responsible for the UI. It obtains its information from the Presenter, and also forwards its input there. Therefore, the View should only depend on the Presenter.*

  • The Presenter is there to provide data to the UI and to manipulate the Model according to the input provided by the View. Therefore, it must depend on the Model.

  • The Model implements your domain logic and should depend on nothing else (except the standard library and possibly some custom utilities).

Where does the data access belong, and how do its dependencies look like? That's something the MVP pattern does not really concern itself with. However, standard best practices still apply.

The domain layer should not depend on anything, including the data access layer. The data access layer, on the other hand, has to depend on the domain layer - it must create domain object after all. There are three reasonable options:

  • The domain layer handles data access itself, by relying on interfaces that the data access layer implements.

  • The domain layer knows nothing about data access, which is handled by the Presenter. This goes somewhat against the philosophy of restricting the Presenter to connecting the UI with the model, but may still be practical in smaller projects.

  • You introduce an additional API layer between the presenter and the business logic. The Presenter talks to the API layer, which has references to the data access layer. Ideally, this layer still does not depend on the DAL, but on interfaces. Concrete instances from the DAL are injected (see Dependency Injection) into it.

* Bonus points if you make both of them depend on a ViewModel instead, with no direct dependencies between the View and the Presenter at all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.