Android MVP – Presenter displaying values (best practices) Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Android MVP – Presenter displaying values (best practices) without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I started to learn MVP but I have a few questions related the Presenter. For example, if I have a really simple Activity that only displays a few information that I got from another Activity. At the moment I am just displaying the value without sending it to the Presenter.

Should I send the values to the Presenter so that the Presenter will call the methods in my Activity to display? Or can I just “ignore” the Presenter?

Answer

Should I send the values to the presenter and the presenter will call the methods in my activity to display?

You should.

Or can I just “ignore” the presenter?

You better should not.

One of the benefits of structuring your code using the MVP pattern is the ability to unit test the structural units. Any Presenter should be framework- (in Android, meaning view- ) independent which makes it possible to unit test it. So, if you “ignore” the Presenter you won’t be able to unit test the Activity methods invocations.

For commercial app development unit testing is a relevant part.

We are here to answer your question about Android MVP – Presenter displaying values (best practices) - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji