Saturday, January 12, 2008

Traps, Pitfalls and Corner Cases

That Joshua Bloch and Neal Gafter have a lot to answer for! They have caused me much embarrassment and inconvenience this evening. After a long day's interviewing Java developers I thought I'd wind down on the train by reading a few sections of the aforementioned Bloch and Gafter's "Java Puzzlers".



This book is an absolute joy. At the bottom of each right hand page is a short piece of Java code and a simple question. For example the first puzzle is a one line method, and the question "Does the method work?" Of course the answer is no... but why? After each puzzle the next page gives a detailed explanation, which is always informative, lively, entertaining and often surprising.

Even if you think you know the JLS well you might be surprised by how often Bloch and Gafter manage to fool you. On the train I looked at one line of code for about ten minutes. I knew that there was a trick there, but just couldn't see it. When I turned the page and saw how completely I'd be fooled I burst into laughter. My fellow passengers gave me some very strange looks; not all of them entirely friendly. Apparently it is not the done thing to laugh at computer text books on the tube.

And the inconvenience? Well I was so engrossed in one problem that I missed my station - the first time in decades of commuting. Oh, those crazy Google engineers!

1 comment:

Joshua Bloch said...

Thanks! It's nice to know that people are enjoying the book.

Josh and Neal