Abstract layers
This section looks at abstract layers using 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 almost anything this way, which is nothing more than applying the Dependency Inversion Principle (DIP).
Let’s start with some context and the problem:
- The domain layer is where the logic lies.
- The UI links the user to the domain, exposing the features built into that domain.
- 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 14.6: Replacing the data...