Creating the domain layer
In this section, we will discuss how to build the domain layer and what goes into it through certain examples. Finally, we will look at an exercise in which a domain layer is created.
Because the domain layer sits at the center of the application, it will need to have a minimal number of dependencies. This means that the Gradle modules that form the domain layer will need to be the most stable modules in the project. This is to avoid causing other modules to change because of a change that occurred in a dependency that the domain modules use. The domain should be responsible for defining the entities and use cases for the application.
Entities are represented by objects that hold data and are mainly immutable. Let's assume we want to represent a user as an entity. We might end up with something like the following:
data class User( val id: String, val firstName: String, ...