- 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
Why in all that is holy doesn't this just return a row count for each? Either it will be null, or a positive number.
Admin
Does that work? Maybe it's different in C-Octothorpe, but I'd expect a
try
without anycatch
blocks to not actually catch anything .Admin
Haha you are right, same thing in C#, it doesn't catch anything and the exception bubbles right out. These people are .... very inexperienced.
Admin
No it doesn't. A finally block is executed even if an exception occurs in the try block, but then the exception is rethrown. So, these try blocks don't actually catch anything.
Admin
I have to admit I thought it would work as well, so I tried it. @Tom is right, you need an empty catch block at least. I would also argue that the bare minimum you should do is have a catch block with a comment in it to say why it's ok to ignore the exception.
Admin
If at first you don't succeed.....
Admin
Finally again, naturally.
Admin
Even if it did work, it never resets the font style / color back to normal.
Admin
That's no problem -- there's an almost identical block of code with a bunch of "NOT"s inserted.
Admin
Don't get me wrong; it's downright without ugly w/o an alibi, but it would still work if any conditions that would throw an exception never occurred.
I have a feeling that the evolution was: "warning: such and such throws an exception - you need a try/catch" - adds try/catch with empty catch .... "warning you can't have an empty catch" - (coyly, but incorrectly) replaces 'catch' with 'finally' .... it works, because whatever is going to trip the exceptions never happens.
That only leaves one question - if the exception bubbles up and the coder gets warnings/errors about uncaught exceptions, then any code calling this one must have some sort of try/catch in it... so.... does it??
Admin
TRWTF is mixing low level DB access code with UI updating code. I'd love to see the unit tests.
Admin
Depending on the version of C# in play here (which I am not terribly optimistic about), the various null checking operators could have been used to avoid any exceptions:
This is, perhaps, not a very pretty way of handling the situation, but I would consider it leaps and bounds above the failed attempt at exception handling.
Admin
This..."works" in that it creates the correct output. However, if any stage failed it throws an exception (which I suspect is being consumed at the top of the tree--the sort of people who do this would likely handle it that way) and it doesn't reset the font if the pending count drops to zero.
Admin
"We don't need tests or code reviews."
Admin
Gotta love how they're converting the enum values to ints. Like they didn't design the methods to accept the enum type but rather the raw int values.
Admin
I... may have a cow-orker who works hard at screwing up indentation that badly.
Admin
About the indentation: Does whatever text editor they are using allow having some indents with spaces and some with tabs? A file with mixed indents might look OK in the one editor, but a print utility, a different editor, or the same editor with different settings may all render the tabs differently.
But that's a problem from the days when we used vi or a similar editor for everything because that was all we had. I can see no reason a professional programmer isn't using an editor that both corrects that problem by saving the file with all indents done the same way, and recognizes the structure of the particular program language and flags any wrong indents.
Admin
This kind of code makes me want to be a full time code reviewer, with the right to slap people in the face when they provide this quality of code.
Admin
They
try
… but ultimately still fail.The indentation makes me want to open the file up in
vi
and typeggVG==
… what did they edit this with, butterflies?Admin
I've never seen warnings in Visual Studio for not catching exceptions that might issue. .NET doesn't have exception specifications, so there isn't any way for the compiler to know that an exception could issue from code unless there is an explicit throw in it. The only way they could be trying to address such a warning is if it came from a linter/analysis tool.