Is generic Money<T_amount> a good 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:01 UTC
Read the original article Hit count: 479

Filed under:
|

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 or long 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

Related posts about .NET

Related posts about c#