Tuesday, January 24, 2012

Major code irritants

I could not agree more with this Java anti-pattern: Storing money in floating point variables.

In my interviews of Java candidates (or C++, for that matter) I always include questions about creating a hypothetical Money class, and pay close attention to their ideas for representation. International candidates often fare better on not assuming US dollars, but most all candidates fail completely on avoiding floating point.

2 comments:

Stephen Colebourne said...

Hopefully Joda-Money http://joda-money.sourceforge.net/ will help, and the new JSR-354 - http://jcp.org/en/jsr/detail?id=354

Brian Oxley said...

Hear, hear!