A brief list of interesting things, culled from the items I shared in Google Reader in the last week:
- Ireland accepts two Guantánamo inmates
- Looks like there’s a new way to get Irish residency. It might even be easier than the traditional approach.
I'm Rory Parle, an Irish software engineer living in London.
A brief list of interesting things, culled from the items I shared in Google Reader in the last week:
A brief list of interesting things, culled from the items I shared in Google Reader in the last week:
If the title didn’t tip you off, this is going to be a technical post. So you might want to skip it if you’re only here to read about how my thumb is doing (very well, incidentally).
Anyway, onto the subject at hand.
I recently had cause to look at the list of bugs that FindBugs looks for when analyzing your Java code. If you haven’t heard of it, FindBugs is a free software static analysis tool. In a nutshell it looks through your source code trying to find coding patterns that it knows can be the causes of bugs. It’s not a replacement for testing by any means, but it is a useful addition to your quality tools.
What’s especially useful is the fact that FindBugs tends to uncover bugs that you might not even know are possible—and thus probably haven’t tested for. Have a look at the list of issues it looks for to see what it can do. There are a few hundred issues listed there, so this could take you some time. I’ll wait.
Assuming you didn’t bother to read about all of those bug types, I’m going to call out one that I found particularly interesting. It’s what FindBugs calls, “Bad attempt to compute absolute value of signed 32-bit hashcode”. As the tool’s documentation describes it:
This code generates a hashcode and then computes the absolute value of that hashcode. If the hashcode is
Integer.MIN_VALUE
, then the result will be negative as well (sinceMath.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE
).
The interesting point here is that last parenthesized statement, that the expression Math.abs(Integer.MIN_VALUE)
is equivalent to Integer.MIN_VALUE
. It’s a surprising result, and one that can cause real problems if the programmer responsible for the code was expecting that call to always yield a positive value.
Recall that the range of integers that can be represented in 32 bits is -2,147,483,648 – 2,147,483,647. That is, the true absolute value of Integer.MIN_VALUE
can not be represented as an int
. The possibilities—from the perspective of the person who designed the Math
library—are to have Math.abs()
throw an exception when passed that argument, or to just return the number as-is. Neither of these are particularly useful to the developer, since the error condition only shows up only one time in over four billion.
The FindBugs blog has more on this potential bug, including some examples of when it might occur. Author Bill Pugh explains why the case of calling Math.abs()
on the result of a hashcode computation is a particular source of trouble.
Now that you’re aware of the potential for this bug to crop up in your code, what should you do about it? Well it would certainly help to run FindBugs against your codebase periodically to look for this bug and others. It really is amazing how many issues can show up even in well-tested code. The potential for human error in complex systems is almost limitless.
If you’re not happy with relying on static analysis and want to test for the bug in a unit test or regression test, you might find use for a string whose hashcode happens to be Integer.MIN_VALUE
. Examples of these, again from the bug’s documentation, are “polygenelubricants” “GydZG_” and “”DESIGNING WORKHOUSES”. Take your pick.
A brief list of interesting things, culled from the items I shared in Google Reader in the last week:
A brief list of interesting things, culled from the items I shared in Google Reader in the last week:
A brief list of interesting things, culled from the items I shared in Google Reader in the last week:
Living in London allows you to do some things that were never really available at home. For example, I now have the realistic prospect of participating in a TV game show. One of the ones that you watch with incredulity while sitting at home with man flu, perplexed by the incompetence of the participants. Who hasn’t dreamed of laying the intellectual smack-down on the contestants of Wheel of Fortune?
I also now have the ability to order beer in quantities smaller than a pint and not get a look of deepest suspicion. That was never an option at home.
Something I’m more immediately interested in than either the game show or the girl’s drink is to watch a TV recording. I’ve done this at home (where “home” refers to Dublin here; I’m still adjusting), but back there you’re limited to a handful of middling quality shows.
London, on the other hand, is the home of the BBC, and is the location where many of the best shows in the world are recorded. It would be a boon to be able to know when tickets for these shows—which are invariably free—become available.
Good thing this listing has an RSS feed then. It’s just one more reason to love the BBC, and the Internet.
I can’t remember the last significant blog post I wrote—in fact I’ve been pretty thoroughly out-posted by one of my more prolific WordPress plug-ins recently—but in the time I’ve been away one thing stands out as the major change in my life. One experience that is entirely new to me. One thing that has changed my perspective on things. One adventure that I had never dreamed of embarking on. One effort that took months to complete, but is finally done.
I’ve grown a new thumbnail on my right hand.
It’s a little lumpy in places because the old nail was still there during much of the new one’s growth, and it’s still uneven at the free edge. But when I look at it I still get that sense of pride in one’s own achievement. It may be crap, but I made it myself. From scratch.
There is not much to tell about the time in which I grew the nail. I damaged its predecessor around the time that the closure of Google Dublin’s software engineering section was announced. My infected thumb gave me all the motivation I needed to skip out on most of the group therapy sessions that ensued from that news. Instead I spent my time waiting in doctors’ offices while swigging from a bottle of children’s strength painkillers.
Once the whole process had kicked off I pretty much relegated the nail growth to a background task. Given the anguish that accompanied the original injury, the bulk of the recovery was surprisingly easy. Even the protrusion of my injured appendage predicted by adage failed to occur. This sore thumb remained resolutely in place.
In the weeks that followed I made plans for the future—plans which confidently assumed the presence of a full complement of digits. I met new colleagues and awkwardly shook their right hands with my left. I bid farewell to the friends and colleagues who had helped—or at least failed to actively hinder me—with my recovery.
Last week I packed up my possessions in the manner of one who has been reduced to a single useful opposable digit. All of it was boxed up and stashed in my parents house to await the movers—people who, as professional relocators, are presumably in prime shape to use all of their thumbs.
Then, only seven days ago, I flew to London to start my new life with my new thumbnail.
A brief list of interesting things, culled from the items I shared in Google Reader in the last week:
A brief list of interesting things, culled from the items I shared in Google Reader in the last week: