Thursday, November 15, 2007

Occam's Coder

When deciding between two or more choices for a style rule in your team's programming style guide, and all of these lead to code that is equally maintainable, prefer the rule you can explain in the fewest words.

"Readability" is also everyone's goal, but fails as a criterion because it is far too subjective.

Friday, November 9, 2007

What Google Java engineers do while... waiting... for IntelliJ to unhose itself...

This discussion happened on our internal Java mailing list.

Dan: "What libraries do people use for generating PDFs from java?"

Tim: "I used iText. It works pretty well."
Fernando: "+1 for iText."
Steve: "Ditto"
Joseph: "we are using itext..."
Mike: "Calendar uses iText..."
Isaac: "+1 for iText on (Google Spreadsheets)"

Me: "Did six Googlers just AGREE on something in a company-wide mailing list thread?? Did that really just happen?? My God, there really is a first time for everything."

Mike: "I disagree. This assumes that time runs in a single direction. If it doesn't, then if an event occurs more than once then the first time could be called the last time and vice versa so neither can be reliably called a first time."

Me: "I've now gained a new appreciation for the complexity of the problems you folks on the Calendar team have to contend with. Clearly we're moving beyond i18n to i19n: interuniversalization!"

Mike: "Yep. We have an implemention of scheduling in multiple time dimensions ready to go and Jeff allocated a pocket universe for testing but production doesn't want to set up a datacenter there."

Kathrin: "Can't you test in a parallel universe where production has agreed to set up your datacenter?"

Well, I laughed my ass off.

Tuesday, November 6, 2007

Minor API fixes for JDK 7

Josh, Doug and I are proposing a handful of minor API additions to the Java Class Libraries (lang, util, math and reflect) for JDK 7.

The very quick overview of our recommendations:
  1. Static compare() methods for all non-void wrapper classes, not just Double and Float.
  2. Static hashCode() methods on all non-void wrapper classes.
  3. Integer.mod() and Long.mod()
  4. RoundingMode.round(double)
  5. Arrays.concat()
  6. EnumSet.complementOf(Collection)
  7. All JDK maps should implement putIfAbsent(), etc.
  8. Proxy.newProxyInstance(type, handler)
We're pretty confident that these changes will make it into JDK 7, barring any particular controversy that could develop.

Please have a read over the document. What do you think about our proposals? What do you think we've missed?

Saturday, November 3, 2007


if (isBloggingInPseudocode()
&& intendedEffect() == Effect.HUMOR) {
try {
// this line unreachable
} catch (NotFunnyException e) {