Android Development

Android Development

Google's android guide Home Contact

Android Design Patterns

MVC (Model-View-Controller)

MVC separates the application into three interconnected components.

  • Model: This is the data and business logic of the application. It handles operations such as fetching data from a database or a network.
  • View: It displays the data to the user and sends user interactions to the Controller. This typically refers to Activities, Fragments, or custom views.
  • Controller: This is an intermediary between the Model and the View. It processes user input, interacts with the Model, and updates the View.

MVP (Model-View-Presenter)

MVP improves separation of concerns in comparison to MVC by clearly defining roles and decoupling the View and Presenter. It enhances testability and maintainability in Android applications. It is easier to test since the Presenter contains the UI logic and can be tested independently of the Android framework.

  • Model: This manages the data and business logic.
  • View: It displays data and forwards user interactions to the Presenter. Typically an interface that is implemented by Activities or Fragments.
  • Presenter: This acts as a middleman between the View and Model. It retrieves data from the Model and applies the UI logic to decide what to display. It updates the View through the View interface.

MVVM (Model-View-ViewModel)

  • Model: Handles the data and business logic.
  • View: Displays data and binds to properties exposed by the ViewModel, typically in an Activity or Fragment.
  • ViewModel: Exposes data and commands (actions) to the View. It interacts with the Model to fetch data and provides it to the View through data binding or observables. It is lifecycle-aware in Android (via ViewModel from Android Architecture Components).
  • Data Binding: Utilizes Android's Data Binding Library or other observable frameworks like LiveData to automatically update the View when data changes.