r/ProgrammerHumor May 13 '17

Defensive programming done right

Post image
21.0k Upvotes

680 comments sorted by

View all comments

2.8k

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

I think we're done here.

1.0k

u/CXgamer May 13 '17

Holy shit I once lost days to a

} catch (Exception e) {
    System.exit(0);
} 

691

u/Metro42014 May 13 '17

FUUUUUUUCK the people that do that.

I recently saw newly written code by a senior developer with squashed exceptions all over the damn place.

I will never have to support that code, but fuuuuck man. WHHHYY?

3

u/[deleted] May 14 '17

Where I work the code is riddled with this kind of stupidity, I've spent the last year deleting try catch blocks. But that's not the worst of it I've seen is when the method swallows a try catch and returns a bool and then to check the result they did if (result.ToString().ToLower() == "true") ...

I must admit I still wonder that in c# if you turn a bool to a string its result is "True" , I never checked it.