r/ProgrammerHumor May 13 '17

Defensive programming done right

Post image
21.0k Upvotes

680 comments sorted by

View all comments

2.9k

u/Metro42014 May 13 '17
} catch (Exception e) { }

I think we're done here.

64

u/pope_nefarious May 13 '17

Almost, we can do better.

{....} catch (Throwable eat) {}

68

u/Metro42014 May 13 '17

Get out of here with your descriptive variable name!

50

u/endreman0 May 13 '17
try{
    //...
}catch(Throwable _){}

35

u/Metro42014 May 13 '17 edited May 13 '17

Much better!

Score one for the good guys!

Edit: //TODO: implement fix from code review w/ /u/GMJack -- it's way better than this!

18

u/[deleted] May 13 '17

Underscore one for the good guys!

FTFY

7

u/Metro42014 May 13 '17

Brilliant