I am seeing this example in the Microsoft documentation:
Here we can see how the order itemOrderItem
has a reference to the ID of the product, it is the first option that sure people uses to think, me too.
But I was thinking about this and I was thinking, why isn't OrderItem
a value object?
If I use the ID of the product, I have the problem that if after I accepted the order and the description of the product is changed, I will see the new description. So if I want to keep the description that it had when I accepted the order, I can't do in this way.
So I was thinking that perhaps in this case it would be better a value object product, that it will have three properties referecereference, description and provider. I don't need more for an order item. In this way, the information will be store in a columns of the order line table, and then I will can prevent to modify it if the order is accepted.
Perhaps the example is simply to try to be more clear, but really all the examples that I have seen about order and items are in this way, to use the ID of the product.
So in sumarysummary, what are the advantages to use the ID and what are the advantages of the value object?
Thanks.