Pages

Thursday, November 30, 2006

Yet Another Coding Oversight

So I’ve been writing a fair bit of code lately. But I haven’t done it in a while.

I wrote this beautiful bug:
[java]
checkItem = result.get(item.getNumber());
if(checkItem == null)
{
result.put(item.getNumber(), new ViewItem(item));
}
checkItem.getDetails().add(new DetailsView(details));

No need to know what Items and Details really are. You can think of items having details if you need to know: let’s see how long it takes someone to spot it.

-= Comments
1. Zooba | November 29th, 2006 at 2:33 pm
The last line will always (attempt to) execute regardless of the check for null above it.

Since I don’t know what the intention is I can’t suggest a solution. I’ll also avoid starting a ‘why not do it this way’ discussion

No comments:

Post a Comment