MVP Architecture

Overview

The Model-View-Presenter pattern

In our app, we follow the MVP pattern, separating the internal data model, from a passive view through a presenter that handles the logic of our application and acts as the conduit between the model and the view.

92ec579c7c197eb1

In the Android Studio project, the code is structured by feature. You can select the Android option in the left navigator to view the files by package.

left navigator

Each package contains 3 different files:

  • Activity: This is where all the view logic resides.

  • Presenter: This is where all the business logic resides to fetch and persist data to a web service or the embedded Couchbase Lite database.

  • Contract: An interface that the Presenter and Activity implement.

Throughout this tutorial, we will walkthrough the code in the various presenters to showcase different features of the Couchbase Lite 2.0 API: BookmarksPresenter.java, HotelsPresenter.java, SearchFlightPresenter.java and BookingsPresenter.java.