Separating the Domain model from Data models
Inside the Domain layer, apart from Use Cases, another essential business component in our app is the Domain model component. The Domain model components are those classes that represent core business data or concepts used throughout the application.
Note
Since the Domain models reside inside the Domain layer, they should be agnostic of any third-party library or dependency – ideally, they should be pure Java or Kotlin classes.
For example, in our Restaurants app, the core entity used throughout the app (retrieved, updated, and displayed) is the Restaurant
data class, which contains data such as title
and description
.
If we think about it, our Restaurants app's core business entity is represented by the restaurant itself: that's what the application is about, so it's only natural that we would consider the Restaurant
class as a business entity.
Note
In Clean Architecture, Domain model classes are often...