I think you're after the Quantity
pattern as described here by Martin Fowler:
... But using objects invites us to add new fundamental types whenever they add value, and having a specific type for dimensioned quantities adds quite a lot of value.
Question
If I have a Tank
entity, would it be correct to have a Capacity
value consisting of Capacity.Value
and Capacity.Unit
?
I would usually have Tank.CapacityValue and Tank.CapacityUnit, but I think this is not correct in a DDD scenario. Thank you for your input.
Solution
I think you're after the Quantity
pattern as described here by Martin Fowler:
... But using objects invites us to add new fundamental types whenever they add value, and having a specific type for dimensioned quantities adds quite a lot of value.