3 ms·
I'm not sure what your point is. It's glaringly obvious that this code is functionally wrong, in no small part bc of the type information.
by joshuamorton 6y ago
I'm not sure what your point is.
It's glaringly obvious that this code is functionally wrong, in no small part bc of the type information.
- CraigJPerry 6y agoAhh 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.