Discover more from MB_Coder Newsletter
What is the Domain Layer in Android Dev?
The domain layer is another layer in app architecture which is sits between the data and UI layers.
The domain layer is used to simplify your architecture and make it easier to understand as well as more scalable and simpler to test.
The domain layer holds business logic like a set of rules and actions that make your app valuable.
Business logic is different from UI logic,
UI logic defines how to display things on screen whereas business logic defines what to do with events and data changes.
Examples of business logic:
getting the latest news articles in a news app or showing an error message if there's no internet connection and in smaller apps, this logic is often held in view models or in the data layer as the app grows it may make sense to consolidate all that logic into a new layer (the domain layer).
it's important to note that the domain layer is not responsible for how data is displayed that's the job of the UI layer and it's not responsible for storing or retrieving data because that's the job of the data layer.
The domain layer only holds business logic.