I see some samples referencing the Domain Layer from DAL. I see that the repository interfaces are defined in the Domain Layer and since the DAL implements them, they need to reference the Domain Layer. The DAL also needs to know the Entities to return so the reference upstream. I thought that we only reference "downstream", can someone explain?
Asked
Active
Viewed 1,567 times
1
-
The simple answer "Yes, DAL should be aware of Domain Model. All other layers are built on top of the Domain Layer." – Ilya Palkin Jun 15 '14 at 18:01
2 Answers
4
Yes, that's OK.
Think about it like this:
If you are going to change (replace) any layer, what layer will it be? It's highly unlikely that you'd change your domain layer, since that would change your entire application. If you change the DAL, then you shouldn't need to modify the domain layer.
So, it's a good thing that your domain does not depend on anything. Your DAL can depend on your domain since your domain is the meat of your application.
I have written an article about this which explains this in more detail:
http://www.kenneth-truyers.net/2013/05/12/the-n-layer-myth-and-basic-dependency-injection/

Kenneth
- 28,294
- 6
- 61
- 84
2

Yorro
- 11,445
- 4
- 37
- 47
-
Should'nt the unit tests be able to access the Domain directly ? After all most of my business logic will lie in the domain layer. – Sudarshan Aug 01 '14 at 09:21