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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top