6. Earlier Approaches
Martin Fowler:
A large proportion of the computers in this world manipulate money, so it's always
puzzled me that money isn't actually a first class data type in any mainstream
programming language.The lack of a type causes problems, the most obvious
surrounding currenciesโฆ
see http://martinfowler.com/eaaCatalog/money.html
6
7. Earlier Approaches (2)
Eric Evans โ Time and Money:
On project after project, software developers have to reinvent the wheel, creating
objects for simple recurring concepts such as "money" and "currency". Although
most languages have a "date" or "time" object, these are rudimentary, and do not
cover many needs, such as recurring sequences of time, durations of time, or
intervals of time. โฆ
see http://timeandmoney.sourceforge.net/
To be quite frank, their code isnโt more than an academic POC, factories
called dollars() or euros() are useless in real globally deployed frameworks,
but he made a good point.
7
10. Summary
โข This JSR will provide a money and currency API for Java,
targeted at all users of currencies and monetary
amounts in Java.
โข The API will provide support for standard ISO-4217 and Custom
(e.g. Virtual) currencies, as well as representation of a monetary amount.
โข It willsupport currency arithmetic, even across di๏ฌerent currencies, and
foreign currency exchange.
โข Additionally, implementation details surrounding serialization
and thread safety are to be considered
10
11. Why is it needed?
โข Monetary values are a key feature to many applications.
โข The existing java.util.Currency class is strictly a structure usedfor
representing ISO-4217 standard currencies.
โข No standard value type to represent a monetary amount.
โข No support for currency arithmetic or conversion
11
12. Challenges
โข Keep it simple โ Remember the most common use case
โขAdding currency values e.g. in an e-commerce app.
โข Performance
โขHow to support low latency applications, such as High Frequency
Trading apps.
โข Precision
โขThere can potentially be differing precisions specified for arithmetic,
currency exchange and formatting
12
13. Challenges (2)
โข Formatting
โขRequirement should be to use existing Number Formats.
โขHowever there is no existing format representing for example Indian
Rupees:
which might look something like this: 12,34,00,000
โขNatural language support for non-decimal valuations for example
โข
Lakhs
โข
Crores
โข
1 Lakh = 100,000
โข
1 Crore = 100 Lakh 13
14. Challenges (3)
โข Formatting
โข12,34,56,000.21 is written
12 Crore, 34 Lakh, 56 Thousand Rupees and 21 Paise
โข Support for non-standard rounding modes
14
15. Non-standard Rounding Modes
โข It is a big world, and each country has its regulations and cultural nuances
for expressing currencies in natural language, rounding policies, groupings,
etc.
โข For example, in Argentina rounding is prescribed for the third digit after
the decimal point:
If the third digit is 2 or less, change it to 0 or drop it.
If the third digit is between 3 and 7, change it to 5.
If the third digit is 8 or more, add one to the second digit and drop the third digit or change it
to 0.
15
16. Non-standard Rounding โ Argentina
Argentina Rounding Examples
Original Number Rounded Notes
123.452 123.45 Third digit<3 round down
123.456 123.455 3<=third digit<=7 change to 5
123.459 123.46 Third digit>=8 round up
Switzerland uses a similar rounding strategy.
16
17. Risks
Plan โ โMoney and Currencyโ is a formidable and dynamic category with
regional dependencies, requiring programmers, business users, international
accountants, and attorneys.
Risk โ Incomplete or outdated spec
Mitigation โ Resulting API should be flexible, let application developer
change implementation as needed.
17
18. Risks (2)
Plan โ There is also a Java dependency on JDK NumberFormat.
Risk โ NumberFormat may require coordinated modifications.
Mitigation โ Coordinate with JDK release;
Supply NumberFormats and similar classes that augment JDK content.
Plan โ There is also a Java dependency on JDK NumberFormat.
Risk โ NumberFormat may require coordinated modifications.
Mitigation โ Coordinate with JDK release;
Supply NumberFormats and similar classes that augment JDK content.
18
20. Expert Group Members
โข Credit Suisse
โข Goldman Sachs
โข Stephen Colebourne
โข Ben Evans
โข Werner Keil
โข Bob Lee
20
21. Supporting the JSR
โข Credit Suisse
โข Caxton Associates
โข Goldman Sachs
โข JP Morgan/Chase
โข London Java Community
โข Stephen Colebourne
โข Werner Keil
21
22. Schedule
โข Targeted to Java 9
โข Aiming at Java ME/Embedded 8 or 9
โข Following the EC Merge and Standard/Embedded harmonization, no JSR should be SE/EE or
ME only, with very few, specialized exceptions. Money is so important, and has almost no
legacy in the JDK except java.util.Currency, that it should be supported by ALL POSSIBLE
platforms, except maybe JavaCard for now.
โข With back-port to previous versions still supported and in relevant use
22
24. Facebook Credits
What are Facebook Credits?
โข Facebook Credits are a virtual currency you can use to buy virtual goods
in any games or apps of the Facebook platform that accept payments. You
can purchase Facebook Credits directly from within an app using your
credit card, PayPal, mobile phone and many other local payment methods.
โบ Hence any such purchase is practically a conversion,
similar to if you buy a foreign currency when
travelling abroadโบ
24
25. Top 10 Video Game Currencies
1. Gold
2. Gil
3. Rupees (not Indian;-)
4. Credits
5. Gold Rings
6. Hearts
7. Zenny
8. Potch
9. Munny
10.Nuyen 25