Google rewrote the Architecture Guide at the end of 2021
See this news: Rebuilding the Guide to App Architecture is Google’s official news blog, released in December 2021. Says the App Architecture Guide has been updated in response to community demand.
Including some best practices and suggested architecture, let’s take a look at what they have.
The suggested architecture
Let’s start with the most important part, the app architecture diagram.
Still, it follows two starting points of architectural design:
- The Separation of concerns.
- Drive UI from Data Models: Data-driven UI.
Each app will have three layers:
- The UI layer is responsible for displaying application data on the screen.
- The Domain layer. This layer is optional and can be used to simplify and reuse the interaction between the UI and data layers.
- Data layer, which contains business logic and exposes application Data.
UI layer
The UI layer is also called the Presentation Layer.
It basically consists of two things:
- UI element: View or Jetpack Compose.
- State holders: ViewModels. They hold data and expose it to the UI and process logic.
For more discussion of the UI layer, see UI Layer.
Data layer
The Data layer includes the business logic: how the app creates, stores, and changes Data.
The Data layer is composed of repositories, each repository can have zero to multiple Data sources.
For a separate introduction to the Data layer, see Data Layer
Domain layer
Domain Layer is optional between UI layer and data layer and is not required by all apps.
The primary purpose is to encapsulate complex business logic, or simple business logic that needs to be reused by multiple ViewModels.
Classes in this layer are usually named Use Cases or Interactors. Each use case should have a separate function.
For a separate description of the Domain layer, see Domain Layor
What was it before: MVVM
The previous architecture diagram is a classic MVVM pattern.It is speculated that this wave of changes is intended to make the concept of architecture more abstract and upgraded to deal with more practical problems and complex scenes.
Actions
The government has provided a learning pathway for everyone to learn.
Reference
- Android-developers.googleblog.com/2021/12/reb…
- Developer.android.com/jetpack/gui…
- Developer.android.com/courses/pat…