But it works ...
-
There are increasing numbers of questions being posted with code similar to:
try { callAPIMethodThatReturnsStatus(some parameters) } catch (SomeException e) { take exceptional action } display ('The method completed successfully');
And yet they never check the returned status of the method call. Someone is teaching students/newbies that if it does not throw an exception then it must have worked. This seems most common with database update commands. Get your money out of the bank quickly.
-
There are increasing numbers of questions being posted with code similar to:
try { callAPIMethodThatReturnsStatus(some parameters) } catch (SomeException e) { take exceptional action } display ('The method completed successfully');
And yet they never check the returned status of the method call. Someone is teaching students/newbies that if it does not throw an exception then it must have worked. This seems most common with database update commands. Get your money out of the bank quickly.
Maybe the return type of callAPIMethodThatReturnsStatus was poop and the programmer didn't want to deal with that s#!t.
Kitty at my foot and I waAAAant to touch it...
-
There are increasing numbers of questions being posted with code similar to:
try { callAPIMethodThatReturnsStatus(some parameters) } catch (SomeException e) { take exceptional action } display ('The method completed successfully');
And yet they never check the returned status of the method call. Someone is teaching students/newbies that if it does not throw an exception then it must have worked. This seems most common with database update commands. Get your money out of the bank quickly.
Not to mention the headless use of try-catch - I wonder who will pay the bill at the end...
Skipper: We'll fix it. Alex: Fix it? How you gonna fix this? Skipper: Grit, spit and a whole lotta duct tape.
-
Not to mention the headless use of try-catch - I wonder who will pay the bill at the end...
Skipper: We'll fix it. Alex: Fix it? How you gonna fix this? Skipper: Grit, spit and a whole lotta duct tape.
-
There are increasing numbers of questions being posted with code similar to:
try { callAPIMethodThatReturnsStatus(some parameters) } catch (SomeException e) { take exceptional action } display ('The method completed successfully');
And yet they never check the returned status of the method call. Someone is teaching students/newbies that if it does not throw an exception then it must have worked. This seems most common with database update commands. Get your money out of the bank quickly.
Well, I saw such type of code also at the then biggest vendor of hospital information systems... But they were one step better than your example: they stored the return value of the call to third party in a variable, which they never checked. That's an enormous step forward already, isn't it?
-
Well, I saw such type of code also at the then biggest vendor of hospital information systems... But they were one step better than your example: they stored the return value of the call to third party in a variable, which they never checked. That's an enormous step forward already, isn't it?
Reading this thread reminds me of a short story that I read long ago. I can no longer remember whether I was in high school or college; the only reason that has any relevance is that I have forgotten the story, but not its title, "Insert Flap A and Throw It Away." I have learned, and am periodically reminded of its importance, that if a function returns a value, even if it is poop, you would do well to check it. After all, if the author thought it was important enough to return, who am I to brush him off by ignoring it? Plenty of authors have written plenty of functions that return void. In all versions of BASIC, these are called Subs, short for Subroutines. Their author is effectively saying, "I have nothing to report; just trust me." A couple of weeks ago, I ran across a method that returns void that I wish didn't. The method in question,
Console.WriteLine()
would be much more useful if it returned a character count, along the lines of what you can get fromprintf()
, but probably aren't. Almost every example I see that uses printf() doesn't bother with the return code. This is so prevalent that I hadn't given the matter any consideration until I started working with its buffered cousin,sprintf()
. Along the way, I discovered that both have a return value of type int, which returns the number of characters written. While the newer "secure" print functions in the latest Visual C runtime library return minus one to indicate failure, even the old ones can be persuaded to print nothing and return zero.David A. Gray Delivering Solutions for the Ages, One Problem at a Time Interpreting the Fundamental Principle of Tabular Reporting