Value vs Entity objects (Domain Driven Design)

后端 未结 8 996
眼角桃花
眼角桃花 2020-11-27 10:10

I have just started reading DDD. I am unable to completely grasp the concept of Entity vs Value objects.. Can someone please explain the problems (maintainability, performan

相关标签:
8条回答
  • 2020-11-27 10:44

    address can be entity or value object that depends on the busiess process. address object can be entity in courier service application but address can be value object in some other application. in courier application identity matters for address object

    0 讨论(0)
  • 2020-11-27 10:44

    I asked about this in another thread and I think I'm still confused. I may be confusing performance considerations with data modelling. In our Cataloging application, a Customer doesn't change until it needs to. That sounds dumb - but the 'reads' of customer data far outnumber the 'writes' and since many many web requests are all hitting on the 'active set' of objects, I don't want to keep loading Customers time and again. So I was headed down an immutable road for the Customer object - load it, cache it, and serve up the same one to the 99% of (multi-threaded) requests that want to see the Customer. Then, when a customer changes something, get an 'editor' to make a new Customer and invalidate the old one.

    My concern is if many threads see the same customer object and it is mutable, then when one thread starts to change it mayhem ensues in the others.

    My problems now are, 1) is this reasonable, and 2) how best to do this without duplicating a lot of code about the properties.

    0 讨论(0)
提交回复
热议问题