Domain Driven Design Lazy Loading
It was a monday.
Domain driven design lazy loading. While that conversation was centered around bypassing repositories for access data which is not true since your aggregate roots are. All criticism of the lazy loading boils down to performance issues and the n 1 problem. To prevent this eager fetch i will need to rewrite my domain. Browse other questions tagged domain driven design or ask your own question.
Viewed 3k times 3. Use lazy loading only in writes handwrite sql queries in reads. So in my opinion you have come to the correct conclusion the domain model should only contain current transactional state. Does lazy loading via properties violate domain driven design principles.
Some comments to a recent post on jeremy miller s blog raised the question of whether nhibernate s lazy loading capabilities violate domain driven design. Lazy loading eliminates the need for additional hops between the domain model and controllers. Archived forums. It s straightforward when using nhibernate and proxies.
A simple query layer best serves that purpose. Lazy loading is beneficial in writes in terms of performance and simplicity lazy loading is harmful only in reads. Blog last minute gift ideas for the programmer in your life. This is something that should not be done.
But how would you implement it without. I am fairly new to domain driven design ddd but what i understand of it is that you speak to the application service which is the entry to your model. Even this solution won t solve your lazy loading problem since to perform an operation on a child entity you will end up loading all the child entity. Ask question asked 7 years 5 months ago.
Assuming that you have a customer with a list of orders lazy loaded if you want to report order totals for every customer you re essentially selecting your customer and. Lazy loading and other fetching strategies indicate that the domain model is being used to perform queries. The service can talk to a repository which uses. The drawbacks of the lazy loading can be overcome by the adherence to cqrs.
Hello i m sorry if the questions was already asked but i didn t find exactly what i want in forum archives. Lazy loading provides a good compromise where you load only the data required for the particular business operation while still keeping the domain model rich and encapsulated. Some parties of aggregate should be lazy loaded especially collections but it s sometimes true for associations. The thing is according to my domain design the holding class is an aggregateroot and this automagically tells my datastore to eagerly fetch all dependent entities including the inner list of holding transactions.
It s about complex aggregate retrieval. You may have to have a re look at your design. Domain driven design entity lazy loading. When using lazy loading we found that quite often we incurred more performance penalties than performance gains.