Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

  if(someCrap == null) {
    someCrap = makeNewCrap();
  }
That's more readable and less indented. It's also self documenting.

   } catch (WeirdExceptionThatWillSeriouslyNeverHappenButStupidJavaRequiresMeToHaveATryCatchClauseAnyway f) {
      // do nothing because this exception will never happen and if it happens the user deserves it
   }
Nice joke, don't do this. I don't believe it's the user's fault, and even so either print the stack trace or name the exception `ignored`. It's not that hard to pipe all ignored exceptions in a single catch.

Also, somebody made the conscious decision of making that exception checked, which means it's the implementor's fault for forcing you to catch it. If you want, you can use lombok's `@SneakyThrows`.



I just do this when I don't want to handle a checked exception.

    throw new RuntimeException(e);


> That's more readable and less indented. It's also self documenting.

It also pushes you ever closer to the dex method cap imposed by Android, unfortunately.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: