The advantage of MVP in android

I am new to android development. I want to implement MVP in my project, but I do not know. What are the benefits of using MVP SO. Please tell us what are the advantages of using MVP in android.

+4
source share
4 answers

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

  • Benefits of MVP in General
  • Benefits of MVP in Android

Common benefits from implementing MVP (or a similar architectural pattern such as MVC, MVVM, MVVC, etc.):

  • Clear separation of responsibilities between components. This separation makes it easier to understand and maintain the code base.
  • . , , , , .
  • . , (, ).

MVx . Android, , IMHO, Android MVx :

  • Android ( ). .
  • Android ( ). , , .

MVP Android, :

+14

, , , .., . , .

, , , , :

, EditText, FIND, .

MVP , Activity Fragment:

findButton.setOnClickListener(new View.OnClickListener() {
    @Override    
    public void onClick(View view) {
        callTheNetworkSearchMethod();    }
});

, API ? , Activity , API . ? .

, , , Activity API . Activity, , . , Activity, .

MVP, :

findButton.setOnClickListener(new View.OnClickListener() {
    @Override    
    public void onClick(View view) {
        mPresenter.doWhenFindButtonIsClicked();    }
});

, - , FIND, Presenter, .

, " ".

If you are interested in learning more about how MVP can help with your Android project, along with a complete sample application, check out my MVP article

0
source

I am a Google ad for Android MVP with various technologies: https://github.com/googlesamples/android-architecture

And the article on the interface for the presenter: http://blog.karumi.com/interfaces-for-presenters-in-mvp-are-a-waste-of-time/

-1
source

Source: https://habr.com/ru/post/1661714/


All Articles