News for hackers. Stuff that matters.
Re:New IDE: code bubbles by guelo on Wednesday March 10, 2010 @09:02PM (#1182603)
That might be the correct way to write that code if the situation is not recoverable.

Say you have

    public int doubleFooBarBazQux(Foo foo) {
      return foo.bar().baz().qux() * 2;
    }
That might throw a NPE, but what's the alternative?
Re:New IDE: code bubbles by jrockway on Wednesday March 10, 2010 @10:09PM (#1182769)
I typed this into Eclipse, and it's super-awesome-excellent auto-code-writer decided that it should be:

   public int doubleFooBarBazQux(Foo foo) throws NullPointerException {
     try {
        return foo.bar().baz().qux() * 2;
     }
     catch(NullPointerException e){
        throw new NullPointerException(e.getMessage());
     }
   }
If only there was a right-click option for "improve quality"...
Re:New IDE: code bubbles by ewjordan on Friday March 12, 2010 @01:11AM (#1185937)
Yeah, the generated code is asinine, but what would you prefer? "Improve quality" in this case would just leave out the try/catch altogether. Is there another behavior that would be better, given that we know nothing about foo, bar, baz, or qux?