Ashutosh
Ashutosh

Reputation: 186

Why do we use Base View and Base Presenter for MVP pattern?

in MVP (Model View Presenter) pattern using base view and presenter is common practice. Can we omit them? and why do we use it at the first place?

Upvotes: 1

Views: 985

Answers (1)

Rajan Kali
Rajan Kali

Reputation: 12953

The reason behind using BaseView and BasePresenter is to move common methods across child to parent, for suppose most of your views have showProgress() method , you can stop declaring it in each child and move to parent as in

interface BaseView{
  void showProgress();
}

interface SomeView extends BaseView{
  void someAction();
}

interface OtherView extends BaseView{
  void otherAction();
}

interface NoProgressView { // this view doesn't need progress so avoid extedning
  void dummyAction();
}

Upvotes: 2

Related Questions