Re: Exceptions, Go to Hell!
Goran Pusic <goranp@cse-semaphore.com> wrote:
Frankly, I agree with ?? Tiib. It has been my experience that if my
program threw an exception, any exception, I had to re-write it so
that it no longer threw the exception.
Even if exceptions was due to network failure that prevented a file
from being open? No, that's too harsh.
If we were attempting to open a file, then it was absolutely necessary
for program continuance. Failure meant the program was broken.
That said, I agree that there are situations where you'd say "well,
this ate resources and it needs to be rewritten".
If the code's result is required for proper program functioning, and
it fails (throws an exception,) then the code has to be re-written
so that it won't fail anymore. If the code's result isn't required,
then why call the code in the first place?
(I'll restrict my discussion to OOM conditions).
Approach you're advocating works only where you can, through external
means, guarantee that you'll have enough memory for whatever you want
to do. I'd say that reduces your set of runtime environments.
But in general, that's a tough call. Who's to prevent users from
running the code on a system with less memory? Who's to prevent the
administrator to reduce working set of the process? Who's to prevent
the user to use virtual memory up to the full? Etc.
True. In the shop I'm talking about, our programs were all on game
consoles. We had a lot of guarantees like the ones you are wondering
about.