2 ms·
Ahh no, the code isn’t functionally wrong, take for example: Money(“USD”, 10) + Money(“USD”, 5) This works just fine. We’d need more context about how it
by CraigJPerry 6y ago
Ahh no, the code isn’t functionally wrong, take for example:
Money(“USD”, 10) + Money(“USD”, 5)
This works just fine.
We’d need more context about how it’s used to say whether we’ve made a bad trade off with our design.
The error isn’t represented in the types, that’s why it compiles and runs. The compiler can’t see the design error here, which is fair, it’s a design problem and types don’t fix that - people are free to misunderstand the business domain and happily capture the wrong rules in types.