Shared rich model
In this section, we will look at a layering solution with a shared model. Then, we will piece the notions that have been provided in this chapter together into a Clean Architecture. We saw a similar diagram at the beginning of this chapter, and that's what we are building here: a shared model between the domain and data layers. In the previous project, the data abstraction layer owned the data model, and the domain layer owned the domain model.
In this architectural alternative, we are sharing the model between the two layers; that is, we are using a rich product model. Here is a visual representation of that:
The objective is to directly persist the domain model and skip the copy from the domain layer to the data layer.
We can do this for anemic models too, but it is well-suited for rich models. With a rich domain model, you delegate the job of reconstructing...