- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
The "use exception not goto" to escape a method pattern...
Admin
Hiring the author of that code was the biggest error.
Admin
This is the proverbial negative of
On error resume next
Admin
This is the code Wally (from the Dilbert comic strip) wrote after he famously said, "I'm gonna write me a new minivan this afternoon!"
For those too young to understand this: https://english.stackexchange.com/questions/488178/what-does-it-mean-writing-a-minivan
Admin
The once was a dev fresh from university, who got bitten trying to throw exceptions from Delphi to VB6. He was told to catch the exceptions and use return codes in the interface and then left unsupervised for months. Ever since, his code was exactly like in the article, throughout, even when there were no language boundaries involved.
I wonder if he still does it
Admin
It isn't really a question of being (or not) too young(1) to get it as that understanding the reference requires the rest of the strip as context.
(1) I did read Dilbert at least somewhat back in 1995, just barely, but this one clearly didn't stick in my mind for thirty years.
Admin
Ha, I again have seen similar code. Developers made proper implementations, then management came around and said "OI, when the user breaks something he get's an error, we don't want that, we want it to just go on somehow". And then the developers added tons of ON ERROR RESUME NEXT (or basically try catch) blocks and used result codes to sometimes do something sensible. Obviously the software was a big pile of garbage and it was getting replaced by a new one because the other one was beyond repair (especially since the persisted data was obviously mostly garbage by this point).
Addendum 2024-08-20 11:07: There could be an argument to be made to say in this case the manager was the problem. Equally you could say spineless developers who just do what they were told are the issue. Personally I think it's a little bit of both.
Admin
Yet another case of paid by the pound code. "I need 100 lines of new code today, so I'll just add a bunch of useless exception cases and have some coffee."
Admin
I'll see your "spineless developers" with "developers in a tight job market with a family to support and a mortgage to pay."
Admin
Are you all familiar with the esoteric programming language, complete with tld ideal for here, https://hurl.wtf/ ? Because that programmer and that language may be an ideal match.
Admin
I think we are seeing somebody in authority who doesn't like the exception breaking their routine. And somebody without the power to override who understands that it should break and recreates the exception in their code.
Admin
Oh good grief, with the mention of "one return policy", I now have a mental image of a
catch(Exception e)
that then does anif-then-else-if
cascade ofinstanceof
to find out what the exception was. (I don't think Java at least would let you switch-case over classes. Oh maybe the class names. Oh deity, now I almost want to fake a submission that does that. It would have missing break statements and all.)Admin
No need to fake it... I swear there is code like this in "our Codebase" (C#). Whenever I quit here, I will submit a hundred stupid code fragments.
Admin
No, you see it clearly wrong. It's "developers that can't see the bigger picture, only one step ahead and throw with their actions a whole team into possibly into a situation where they get fired but are often more like cockroaches that already have move on and therefore other people will suffer for their shortcomings" :p
Admin
Normally no, but with
sealed
class hierarchies and the new pattern matching stuff you can do that. You wouldn't usually do that with exceptions.