Abstract layers
This section looks at abstract layers with an abstract data layer implementation. This type of abstraction can be very useful and is another step closer to Clean Architecture. Moreover, you can abstract pretty much anything this way, which is nothing more than applying the Dependency Inversion Principle (DIP).
Let’s start with the problem: the domain layer is where the logic lies, and the UI links the user and the domain, exposing the features built into that domain. On the other hand, the data layer should be an implementation detail that the domain blindly uses. The data layer contains the code that knows where the data is stored, which should be irrelevant to the domain, but the domain directly depends on it.
The solution to break the tight coupling between the domain and the data persistence implementations is to create an additional abstract layer, as shown in the following diagram:
Figure 12.6: Replacing the data (persistence) layer with...