MVP in Android

Rahul Sharma
1 min readMar 22, 2020

--

Why not MVC (Model View Controller) ?

  1. No Separation of concerns

e.g: lifecycle and business logic

2. Difficult to test and debug.

3. Difficult to mange because of large class size.

Model ← → Controller← →View

Model and View both talks to controller regarding update, user action, notify etc. (to much responsibility on Controller)

MVP (Model View Presenter)

Motive is to separate presentation layer from business logic.

Don’t consider that MVP is architecture of your app because this only models presentation layer and rest of layers still require good architecture.

Why to use MVP ?

  1. Well-separated layers
  2. Extensible and maintainable.
  3. Easy to mock and test(test case).
  4. Separates data model from view through presenter.

e.g : suppose we are using some database and later we need to change it then we have to re-write whole code if its MVC but in MVP its a separate layer so just we need to alter that piece of code.

I’ll write sample code in next Story. If you have any doubts please do comment.

--

--

Rahul Sharma
Rahul Sharma

No responses yet