RoDo RoDo - 24 days ago 7
Android Question

Android MVP explaination

I'am new with Android app programming so i try to understand how it works and what the best way is to program an "clean" Android app. I found an interesting article about it where they use an kind of a 3 layer architecture.

Now i read that android uses the MVP design pattern and try to understand this. The way i understand the MVP principle (in the android context) is that:


  • the Model layer are the logic classes

  • the presenter are the classes that are "linked" to an XML (the activities)

  • the passive view are the XML's.



Is this correct?

When this is correct, is it then also correct that the 3 layer model fits perfectly in the MVP principle because:


  1. the presentation layer from the 3 layer architecture fits in the presenter layer of MVP

  2. The business and the data layer from the 3 layer architecture fits perfectly in the model part of the MVP?



I hope my questions are clear because it is an complicated topic for me...
Ohw... and sorry for my bad English!, i'am from Holland.

Maybe this clears up my vision (way of thinking) about this...
Maybe this clears up my vision about this...

Answer

first thing I wanted to clarify is that MVP or any other pattern for that matter is no specific of Android dev and, can be applied to any other framework.

I think you got the gist of it:

  • view is usually implemented by activities and fragments and will contain the reference to the presenter
  • the presenter is that middle man between the view and model. Retrieves data from the model and returns it already formatted to the view so it doesn't need to do anything else but display it.
  • the model can be seen in a simplistic way as the "data provider". It can be as complex as you want, using internal db, lots of clases etc.

If you are interested in Android apps architecture I suggest you watch this talk given at Android dev summit this year. It is one of the bests I've seen

https://www.youtube.com/watch?v=BlkJzgjzL0c

Comments