Naveed
Naveed

Reputation: 75

One domain object 'filled' by several repositories

I am new to DDD and need to clear some concept so that i can apply it on my project.

Basically, i have a domain object "Customer". CustomerRepository would return this domain object by referring the DAL.

The problem is that the DAL cannot provide all the information needed to 'fill' Customer domain object. Some information regarding the Customer will be acquired by some other external resource, maybe some other repository or a external web service.

Maybe i should divide my "Customer" domain object. But what if my business logic doesn't allow me to do so?

Also, is it only repository responsibility to return domain object?

Upvotes: 1

Views: 306

Answers (1)

Arnis Lapsa
Arnis Lapsa

Reputation: 47607

Yes, it should be responsibility of repository.

Storage is cheap nowadays. Maybe doubling that data would solve Your problems? E.g., if customer.firstname comes from data source #1 but customer.lastname comes from data source #2, You could just make sure that on customer registration customer.lastname is stored in data source #1 (+ procedure that would update already registered customers)?

Another thing - Your domain model shouldn't know about this problem. You should try to keep it unaware of technical problems. Otherwise - You will eventually lose isolation and end up with artificial domain objects that are coded there just to make it run.

Upvotes: 1

Related Questions