> Using that logic, one should have absolutely everything that uses memory
> in
> a Try...Catch, even local variable declarations, which is unreasonable.
Local variable declarations don't allocate memory. Maybe you are thinking
of the possibility of a stack overflow exception, but a) you would have to
wrap the calls with try/catch to get those, and b) you can design your
code to easily avoid those, which is not the case for out-of-memory
exceptions.
> The fact remains that, from a coding point of view, putting the
> instantiation of a connection in a Try...Catch does not serve any
> practical
> purpose.
Of course it does. At least for those people who wish to write
applications that don't just crash when memory is restricted.
Your mileage may vary, but it's poor practice for any serious application
to crash, under any circumstances. Including low-memory conditions. If
you don't want to write serious applications, that's fine, but that
doesn't make your generalization about "does not serve any practical
purpose" true. Don't make the mistake of thinking that just because you
don't find something useful, no one does.
Pete
Peter Duniho - 09 Feb 2008 04:52 GMT
> [...]
> Your mileage may vary, but it's poor practice for any serious
[quoted text clipped - 3 lines]
> any practical purpose" true. Don't make the mistake of thinking that
> just because you don't find something useful, no one does.
And lest you misunderstand me: it is perfectly reasonable to catch
out-of-memory exceptions higher up. I am taking issue with your
implication that no one need concern themselves with out-of-memory
exceptions at all.
Pete