|
I log it; I want to know *why* it failed and why I did not consider it as a possible path.
Hence the term "unexpected" - there's also some exceptions that *are* expected
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Then it sounds like the process is organized poorly. If a separate process will "fix it anyway", then why does the original stored procedure need to be done at all?
For that matter, if you've got processes that fix problems in earlier steps, then you've got a system built out of Band-Aid™s.
Software Zen: delete this;
|
|
|
|
|
Gary Wheeler wrote: then you've got a system built out of Band-Aid™s. No, it's called dealing with 3rd party tools.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
You have my sympathy.
I hate dealing with third-party tools in our products. As the DSJB(*) I get to write our installers. I have one product that requires not one but two different versions of the Visual C++ runtime because of third-party dependencies.
(*) Departmental Sh!t-Job Boy
Software Zen: delete this;
|
|
|
|
|
Gary Wheeler wrote: not one but two different versions of the Visual C++ runtime because of third-party dependencies.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Eddy Vluggen wrote: I heard that often Lets say my application wants to see which localized satellite assemblies are installed, so it gets the names of all of the directories in the installation folder and checks which names correspond to valid Country-Culture. The CultureInfo class does not have a method to check if the name is valid. The way to check is to use GetCultureInfo on the directory name and catch the exception if it fails. (It could have returned null if it fails but it doesn't!)
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
- G.K. Chesterton
|
|
|
|
|
That is not an unexpected exception; you are actively catching the exception and continuing on a known path. That is, if you catch exactly that exception, and not just every exception.
Otherwise you might miss it if the user does not have read-rights on that location; that makes for bugs that are difficult to solve, if it is unknown that an unexpected exception is occuring and therewith changing the logic of the application to some unexpected state.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: That is not an unexpected exception; you are actively catching the exception and continuing on a known path. That is, if you catch exactly that exception, and not just every exception.
Yes, it's the swallowing of top-level exceptions that are potentially nasty. I've had to maintain code in which top-level exceptions are swallowed and they swallowed serious errors. To track them down I then had to wade through tons of code.
Kevin
|
|
|
|
|
Me too. I've used that method as loop control where the loop needed to go in sequence (0,1, ...) but it may be missing values. Another was for a HTML form that sends an arbitrary number of arguments - which I sequenced the naming convention but didn't have in an array. In the latter case, the exception was the only way to find the end.
But these were always deliberate.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "As far as we know, our computer has never had an undetected error." - Weisert | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
Not so sure.
If ever that was the case, what is the downside of handling it anyway?
Surely less than the downside of being wrong about that exception being able to be ignored.
And always remember, in .Net you can get a huge performance whack catching and swallowing exceptions (especially DB exceptions).
|
|
|
|
|
Eddy Vluggen wrote: Throwing ex;
As I understand it there's no difference between throw and throw ex in Java, but there is in C#. I suppose that will catch out anyone moving from Java to C#.
Kevin
|
|
|
|
|
Well, my whole system does nothing but Throw (not Throw Ex, or Throw New Ex).
At the top there is an unhandled exception handler, which:
- Shows the error in a message box
- On OK it closes the current program down
- Waits several seconds, then
- restarts the program and puts the user back to (roughly) where they were.
The users prefer that, and there have been very few cases where they got stuck in a loop.
When it did happen, I soon heard about it.
Almost every time they got what they call a "restart", was due to some kind of service fail, LAN, DB, internet, etc.
Most of which self righted fairly quickly.
|
|
|
|
|
D) Use GOTO.
E) Systems Hungarian
But I'd like to add, that you also need to know when to break the rules.
|
|
|
|
|
So, when do you use Systems Hungarian?
Or worse, Apps Hungarian?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
Shouldn't you ask Nagy?
|
|
|
|
|
I'm not going to ask Nagy anything, he might still be upset about the goulasj
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
That is Joels' take.
I rather not see prefixes at all. I can imagine the type, if you're reading from a printout and taking a ... walk, but not "Apps", where different abs got different meanings for each product.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: where different abs got different meanings for each product.
That's the whole point.
|
|
|
|
|
GOTO can be useful and there are moments where it is needed. Misusing it can result in spagetti code I know but...
I would like to see you coding in LAP (PLC) or assembly without JMP instructions...
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
That's why I added the second sentence.
|
|
|
|
|
mmmm... ok. I forgive you
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
There's an example in Code Complete (first edition at least) where they provide a code example using Goto. Apparently almost no-one was able to rewrite the code correctly without using Goto.
Kevin
|
|
|
|
|
Jörgen Andersson wrote: D) Use GOTO. so break and return are not to be used?
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|