dreadedmonkeygod . net

Abomination!

I've ranted before about returning null. Just when I thought I'd seen it all, I find this:
class Abomination {
    public boolean ignore;

    public Foo getFoo() throws FooException {
        try {
            return doDataRetrievalStuff();
        }
        catch (Exception e) {
            if (ignore) return null;
            else throw new FooException(e);
        }
    }
}

Listen up, you primitive screwheads. Never ignore exceptions. Furthermore, you just multiplied the testing burden for this code. I have to test it for cases ignore=true and ignore=false. I have to make sure my code handles both the possible FooException and checks for null, as well as simply doing the right thing with the Foo when all goes well.

So, to the programmer who wrote this: when I find you, I'm going to grab you by the ear and walk you over to your boss, and explain to him/her what a muppet you are.

And then I'm going to explain to him/her that automated testing and QA does not obviate code reviews, especially when you're building a framework that other developers will build on.

Gah!

Post a Comment

Name:
Email (Never, ever displayed.)
URL:
Remember me next time.
Comments (Sorry, no HTML allowed. Space paragraphs with a blank line.):