MVP Design Pattern

When writing an application, being aware of the various design patterns can be a great way to keep your code organized and avoiding one-giant-mess-of-an-activity. A design patter, such as MVP (Model - View - Presenter), may seem like a lot of additional coding efforts up front, but can be very beneficial in the future. MVP is a good way to decouple your code, so iterations to the UI layer will not affect your Model layer, for instance. There are also many benefits when it comes to testing. 

When exploring MVP further, I came across some helpful resources I wanted to share.

One of the most useful resources I've found is an example project from Israel Ferrer. I found this to be a practical and thorough resource. As a bonus, you can listen to him on the Fragmented Podcast episode 26


Here, Jeff Potter builds a simple sample application using the MVP pattern. This example is easy to understand and also demonstrates how to swap out a Synchronous task for an Asynchronous task without any real implications to the UI code.  

An Explanation of Android MVP and the overall design pattern of MVP https://github.com/jpotts18/android-mvp Part 1 - https://youtu.be/qE4DEwrK2N4 Part 2 - https://youtu.be/jyLNF83cMa8 Part 3 - https://youtu.be/rAAV0P8cpaA


Another useful video is called "Building Better Android Apps with MVP" by Anup Cowkur. This is a decent talk that explores the advantages of this pattern for testing. 

Many Android apps are generally written with business logic and data requisition and manipulation all mixed with UI code in activities and fragments. The lack of control over the lifecycles of god objects such as activities further complicates Android app architectures. Without a clear architectural paradigm, testing of this hodge-podge code also becomes a nightmare.