“Perhaps You’re Looking in the Wrong Place”

Interesting quote from a recent interview w/ bug fixer Brian Harry.

The quote itself is actually attributed to James Gosling but I like and can appreciate what Brian has added to it.

“The place where you find bugs may not be the right place to put a fix in.”

Simple example of this: Damn, I’m getting a null pointer in this method, better wrap it in a: if (object != null) doSomething;

Sure, you’ve fixed a symptom but very rarely (or perhaps not necessarily) have you addressed the problem.

Another situation: Damn, hashCode() is slow, when I’m calling it 60 million times it’s taking forever. First thought, hashCode() is inefficient, let’s re-write them (maybe they’re using HashCodeBuilder or doing something inefficiently) and save 20%. Perhaps it’d be more worthwhile to look at why your hashCode() is getting invoked 60 million times, address that, and watch the overall time (total operation, not hashCode()) spent fall from 70s to < 2s.

We all love low hanging fruit, but we shouldn’t let it become a barrier to digging deeper.