antoniolg / androidmvp

MVP Android Example
5.94k stars 1.58k forks source link

Mvp with dagger2 #23

Closed alinhayati closed 6 years ago

alinhayati commented 7 years ago

Thanks for your wonderful and pioneering work on MVP in android. Having gone through your implementation, I found out that there is a direct coupling between View and Model in Line 48 of MainActivity.class, which is not advisable in MVP pattern. I later realized that this was not written originally like this, but later added as a workaround to avoid using reflection in the unit testing of MainPresenterTest.class. To resolve both of the above issues, I refactored the code using Dependency Injection with Dagger 2 and used MainActivity.class as the composition root along with Fragment to handle the view. I also revised the MainPresenterTest.class to test the same five predefined tests without reflection. I think the code is now even clearer to read and understand, thanks to your original prominent work.

antoniolg commented 6 years ago

Thanks for this, but I don't want to add Dagger in this repo. This needs to be as simple as possible so that people who don't know about MVP can understand it. Dagger is too complex.