Panasonic Youth

Top Five Worst APIs in Java

Its monday morning and I forgot my coffee thermos at home. Drinking corporate coffee sucks. Guess I might as well complain about Java.

  • Calendar - Bad.
  • Date - Worse? Date and Calendar might be the most ridiculous Java APIs ever created. With date you can at least say getYear or getMonth, but then the results are the weird "year represented by the date, minus 1900". With calendar you have the wonderful abstract get approach - ie myCal.get(Calendar.YEAR), myCal.get(RANDOM_MEANINGLESS_INT). Would an immutable, easy to use date object be too much to ask for? Couldn't Java 7 just incorporate JodaTime or something?
  • BigDecimal/BigInteger - Steve covers this one must better then I can. Even incredibly simple calculations become a horribly verbose mess with the BigNum objects. One case where you really need operator overloading.
  • ResultSet - why can't I just iterate over everything in my row? Why can't I get a map of the values keyed by column header?
  • Format, NumberFormat, DateFormat, etc. - SimpleDateFormat really isn't, and these classes end up making the smallest task difficult in order to have ultimate flexibility. Not a great trade off for most cases.