I read about MVP patterns. When we are starting developing android applications we are almost by default using MVC (we usually have our models in "models" package, views are inside "res" folder and activities are basically controllers.
I have realized that some activities inside my applications are not very readable, they are easy to understand but it take some read it because of the amount of code (for example,set up listeners for seekBars, handling sending data do AlertDialogs,receiving data from AlertDialog, validation of data before sending to server.
I don't see any benefit of starting using presenter (in MVP pattern). Presenter holds reference to activity, and when I want to do something with my view(change some EditText for example), I will call some method on presenter that points back to some method in my view(activity). All interactions with views are still handled inside activities which makes it hard to read.
Currently I implemented presenter layer just like some facade layer above activity. For example, there are methods like BindModelToUiViews()
that have lot of code for setting up initial views(controls) on screen. What is best practise to make android activities "clean" and more readable(maintanable)?
Aucun commentaire:
Enregistrer un commentaire