Persistence Ignorance is an application of single responsibility principle, which in practice means that Domain Objects (DO) shouldn't contain code related to persistence, instead they should only contain domain logic.
a) I assume this means that the code which contacts lower layers ( ie persistence layers ) lives outside of the domain model in other classes ( OC ) of a business logic layer?
b) If my assumption under a) is correct, then DO, say Customer
, never contains methods such as GetCustomers
or GetCustomerByID
?
c) If my assumptions under a) and b) are correct, and assuming Customer
domain object uses lazy loading for some of its properties, then at some point Customer
's internal logic must contact OC, which in turn retrieves deffered data. But if Customer
needs to contact OC to receive deffered data, then we can't really claim that Domain Objects don't contain logic related to persistence?!
Thank you
REPLYING TO jkohlhepp
1) I assume OrderProvider
and CustomerProvider
classes are contained within business logic layer?
2) I gather from your reply that my assumptions under b) are correct?
3)
... I would check to see if some private orders field was populated or if it was null. If it is null ...
But as far as I can tell, as soon as domain code needs to check whether private order
field was populated, and if it isn't,contacting OrderProvider, we are already violating PI principle?!