I don't quite get how you want to prevent "accidental bugs" by just introducing value objects. Another module/API or another developer could still pass the wrong primitive values (from a different unit of measure) to create the object. The naming is better and more obvious of course.
That's a good point. It is not possible to prevent bugs - but only to minimize (hence I used the phrase "helps reduce accidental bugs"). The naming at least helps us be consciously aware of what kind of units we're talking about, so that the immediate caller of the code is aware of the units. Nonetheless, as you wrote, they could still pass wrong primitive values.
I don't quite get how you want to prevent "accidental bugs" by just introducing value objects. Another module/API or another developer could still pass the wrong primitive values (from a different unit of measure) to create the object. The naming is better and more obvious of course.
That's a good point. It is not possible to prevent bugs - but only to minimize (hence I used the phrase "helps reduce accidental bugs"). The naming at least helps us be consciously aware of what kind of units we're talking about, so that the immediate caller of the code is aware of the units. Nonetheless, as you wrote, they could still pass wrong primitive values.