Vivek Pandey Vivek Pandey - 3 years ago 82
Android Question

Advantage of MVP in android

I am new in android development.I want to implement MVP in my project but I don't know What are the advantages of using MVP SO Please tell me what are the advantages of using MVP in android.

Answer Source

There are two parts to your question as I see it:

  1. Advantages of MVP in general
  2. Advantages of MVP in Android

The general advantages that one gets from implementing MVP (or similar architectural pattern like MVC, MVVM, MVVC, etc.) are:

  1. Clear separation of responsibilities between components. This separation allows for an easier understanding and maintenance of the code base.
  2. Modularity. Modularity allows you to e.g. switch to a different implementation of view component in order to completely change application's UI, while all other components remain intact.
  3. Easier testing. Since there are well defined boundaries between components, it becomes much easier to test each component in isolation (by e.g. mocking other components).

The above are general advantages of MVx on any platform. These also apply to Android, but, IMHO, in Android the gains from following MVx are higher due to the following reasons:

  1. Android framework does not encourage developers to write a clean code (to say the least). Adhering to a clear set of practices in this case is especially important.
  2. Unit testing is damn hard on Android (in several aspects). Therefore, having a clear boundary between components and being able to mock them out is especially important if you want the code to be testable.

If you want to go down MVP path in Android, check out these resources as well:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download