Re:People in your organization that grow legacy code
by ygra on Monday February 24, 2014 @09:37AM
(#7290966)
FWIW, the default Java API to get weekday strings is also 1-based (DateFormatSymbols.getWeekdays(); and Calendar.SUNDAY is 1).
Re:People in your organization that grow legacy code
by anton_gogolev on Monday February 24, 2014 @09:51AM
(#7291048)
Yeah, with Java DateTime API being royally fubarred [1].
2: not 0-indexed (there can be good reasons for this, but the context of the function should at least suggest the reason)
3: Doesn't handle errors - should throw IllegalArgumentException, and if should do it in the default handler of the switch. If you suddenly see "???" in the UI, it's not easy to track down to this.
4: If for some valid reason this can't be a library function, it should be an enum, and it should be used throughout the code.