Reading a little bit about Functional core & imperative shell pattern, I am wondering if the DI principle can be improved.
What happen if instead of having an Infrastructure layer depending on concrete domain objects, e.g.: IUserRepository.Save(User obj)
, we create a Core layer just with abstractions like: IAggregateRoot
, IEntity
, IInvariantValidation
, etc. The Domain layer will implement those interfaces and will have just pure functions. Then the Infrastructure layer will depend only in the Core layer, e.g.: IRepository.Save(IAggregateRoot)
I think this way the infrastructure will remain mostly the same without major changes, and the domain that is easier to test will be very easy to evolve. Then there will be an Application layer that will depend on Domain & Infrastructure layers
Domain -> Core <- Infrastructure
Domain <- Application -> Infrastructure
This is not a concrete question but I want to know if you see some cons in this approach and if it already exists where I can find some material about it.