faq
flatforty
contribute
subscribe
configure
search
rdf
main
parent
thread
|
Re: Support for exceptions
by Dawnrider on Saturday 10/Jul/2004, @07:44
|
The trouble with forcing exceptions to be managed is simply that the majority of programmers don't have time to manage every error, or know every error that might be thrown in a given situation. The classic problem, or course, is whether to continue with potentially bad data/state, or to fail. Exceptions ensure the latter in most cases.
Personally, I prefer being able to explicitly handle errors myself knowing what might potentially happen and how critically it will affect my data and running integrity.
The danger of requiring expressions is best expressed by reference to many, many, many pieces of Java code that are running around with:
try
{
<something>
}
catch (Exception e)
{
<do nothing>
}
It turns up much the same arguments as strong vs. loosely/dynamically typed languages. |
|
|
The Fine Print: The following comments
are owned by whomever posted them.
( Reply )
|
Re: Support for exceptions
by El Pseudonymo on Saturday 10/Jul/2004, @10:13
|
I have seen a bit of C++ code, and I have never seen that style, i.e. writing catch-blocks but not doing anything in them. I suspect that almost no C++ programmer would come up with this idea. I have not seen much Java code, but I think there is the difference of checked exceptions, which do not exist in C++ in the way of Java. Such checked exceptions could lead to that style of coding. So, what I am trying to say is basically, this misuse of exceptions will not be seen in C++.
Also, you will not loose any control of handling errors if exceptions are used. Of course, if you really want to deal with *all* exceptions yourself, surround you code with a catch-all handler. A different question is, if that makes sense (Usually not).
I also think that your argument that many programmers do not have the time to manage every error is a very good one in favour of exceptions, since the default behaviour of terminating if nothing is done is the right thing to do then.
|
[
Reply To This | View ]
|
Re: Support for exceptions
by Nicolas Goutte on Saturday 10/Jul/2004, @12:06
|
I am sorry but terminating is not a good solution: the unsaved document... lost! So for me, it is little different than a crash, so perhaps it is not an abrupt crash but a more controlled one.
(Perhaps you will tell me that you can make an emergency save while for a real crash you cannot. But the end-user will not care, for him it is and remains a crash, as the program has terminated abnormaly.)
Have a nice day!
|
[
Reply To This | View ]
|
Re: Support for exceptions
by El Pseudonymo on Saturday 10/Jul/2004, @13:18
|
Yeah, it is not entirely unproblematic. But I really think ignoring errors is worse. Think of an abnormal situation which prevents an application from being able to save a document. Suppose this condition is detected while opening the file which is being worked on. Suppose that is ignored. The user will be happy with editing his important document, and only after he has made his changes, working for some time, out of a sudden, his data will be lost because he can not save. If the application would have terminated right at the start, I think that would have been the better alternative.
Have a nice Saturday night!
|
[
Reply To This | View ]
|
|
The Fine Print: The previous
comments are owned by whomever posted them.
( Reply )
|
|