Is generic Money<TAmount> a good implementation idea?
Posted
by jdk
on Stack Overflow
See other posts from Stack Overflow
or by jdk
Published on 2010-03-21T00:51:49Z
Indexed on
2010/03/21
1:41 UTC
Read the original article
Hit count: 392
I have a Money Type that allows math operations and is sensitive to exchange rates so it will reduce one currency to another if rate is available to calculate in a given currency, rounds by various methods. It has other features that are sensitive to money, but I need to ask if the basic data type used should be made generic in nature.
I've realized that the basic data type to hold an amount may differ for financial situations, for example:
- retail money might be expressed as all cents using
int
orlong
where fractions of cents do not matter, decimal
is commonly used for its fixed behaviour,- sometimes
double
seems to be used for big finance and large values - sometimes a special BigInteger or 3rd-party type is used.
I want to know if it would be considered good form to turn Money
into Money<T_amount>
so it can be used in any one of the above chosen scenarios?
© Stack Overflow or respective owner