MVP Pattern Android ?

In large applications, it’s essential to organize your code very well. MVP allows you to separate business logic from presentation layer. MVP makes views independent from our data source. In Android, activities and data mechanism will be tightly coupled . With MVP we are able to take most of logic out from the activities so that we can test it without using instrumentation tests.

mvp

Presenter:

Presenter contains the UI business logic for the View and a middle man that talks to the View and the Model. The Presenter is also decoupled directly from the View and talks to it through an interface, this is to allow mocking of the View in a unit test.

View :

This view will implemented by Activity or Fragment will contain the reference to Presenter.

Model:

This is provider of the data we want to display in the view.

Implement MVP pattern:

1. Creating an presenter interface

2. Implementation for presenter – As UI logic will be implemented in this PresenterImpl.

3. Create an view interface- where activities or fragements implements this interface

 

References:

1. http://antonioleiva.com/mvp-android/

 

Advertisements

2 thoughts on “MVP Pattern Android ?

  1. Pingback: MVP Pattern Android ? – Qamar-ud-Din

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s