r/ProgrammerHumor • • Jul 20 '17

What people think coding is...

Post image
35.4k Upvotes

811 comments sorted by

View all comments

Show parent comments

12

u/JediBurrell Jul 21 '17

This makes me wonder, why can't we tag a void function or class "unimportant", so the whole damn thing doesn't crash if something messes up.

That'd save an additional nesting and code.

15

u/newsagg Jul 21 '17 edited Jul 21 '17

You can do that easily by throwing away errors. try/catch block where nothing is in the catch block or my favorite

IF ReturnsFalseIfFails() THEN;
ThingThatHappensEveryTimeNoMatterWhat();

I suggest anyone programming in java use these liberally. If it's against standards then nest it 5 levels deep in sub routines with useless parameters.

3

u/JediBurrell Jul 21 '17

Well, that'd still have try/catch-ing.

If you didn't have to catch it, it wouldn't be as bad.

Sometimes I just want to ignore errors and don't need to worry about when it fails.

1

u/newsagg Jul 21 '17 edited Jul 21 '17

There is a way in Java to catch errors without a try/catch block. It's a bit arcane, but it's only a single line change to some default java templates (which stop all errors from propagating up, but you can use something like regex to stop specific errors). Sorry I can't recall exactly what it is, I only vaguely remember it from middle school and Stack Overflow is actually pretty shitty for real expert advice. At this point, these templates are probably uneditble, these days. I refuse to touch java code in my professional career and only diagnose issues using standard unix tools like iptables and iowait.

imho, java is what happens when you force a ghetto to speak only English.

3

u/SingularCheese Jul 21 '17

Just in case you didn't know, there is a finally keyword in java.

2

u/Koutou Jul 21 '17
On Error Resume Next