Reputation: 2967
Considering Domain Driven Design, can Infrastructure or System use Domain's objects (Values, Entities, etc.), or should it be applied Dependency Inversion, so that Infrastructure will only depend on Interfaces defined by itself?
What about the Repository? Does it applies de same?
Is it a violation to a Infrastructure, Repository or a System code depends on the Domain?
(A) Example code where Infrastructure depends on the Domain:
namespace Infrastrcuture {
public class Sender {
public void Send (Domain.DataValue data) { ... }
}
}
(B) Example code where Infrastructure will not depend on the Domain:
namespace Infrastrcuture {
public interface ISendableData {
...
}
public class Sender {
public void Send (ISendableData data) { ... }
}
}
Upvotes: 4
Views: 1599
Reputation: 28737
In general, I'd say it's OK if your infrastructure depends on your domain. The other way around is not such a good idea.
Think about it this way: what is more likely to be replaced at some point? Infrastructure or domain?
Infrastructure will change over time (different providers, different servers, ...) Your domain on the other hand will always be there
Upvotes: 5