java - Why is the money representation not typesafe? -
what design decision why monetaryamount
not parameterized on currency
?
if have had monetaryamount<usd>
compiler disallow when try add monetaryamount<eur>
- increase robust typing capabilities of api , pleasantness of usage overall.
i know entail have defined class usd
extending interface currency
- api can package iso currencies along crypto-currencies. if user not have pre-defined currency new 1 can defined implementing interface.
thoughts?
edit ok, tone of comments not pleasant see. asker, not claiming smarter library designers. in fact, likes library much. asker pretty sure designers have tinkered idea of using generics on money put off reasons. "reasons", asker wants know - learn something.
Comments
Post a Comment