MV P/C/VM Flashcards
MVC - Standard Android
This is the “default” approach approach with layout files, Activities/Fragments acting as the controller and Models used for data and persistence. With this approach, Activities are in charge of processing the data and updating the views. Activities act like a controller in MVC but with some extra responsibilities that should be part of the view. The problem with this standard architecture is that Activities and Fragments can become quite large and very difficult to test.
MVP
When using MVP, Activities and Fragments become part of the view layer and they delegate most of the work to presenter objects.
Each Activity has a matching presenter.
View — the UI layer. Displays the data and notifies the Presenter about user actions.
Presenter — retrieves the data from the Model, applies the UI logic and manages the state of the View, decides what to display and reacts to user input notifications from the View.
Model — the DATA LAYER. Responsible for handling the BUSINESS LOGIC and COMUNICATION with the network and database layers.
MVP advantages/disadvantages
Advantages
- Presenter preia responsabilitatea lui View sa gestioneze chestii care nu-i intra in responsabilitate.
- Presenter is easy to unit test.
Disadvanvages:
- Developing a small app, this can seem like an overhead
- Presenter becomes a all-knowing class, with thousands of lines of code.