Re: What's finally keyword good for?
- From: Ollis <No@xxxxxx>
- Date: Mon, 8 Dec 2008 12:13:01 -0800
"Christophe Lephay" wrote:
"Ollis" <No@xxxxxx> a écrit dans le message de groupe de discussion :
DDDD1EAE-29A2-4C51-8FB4-7112A4456935@xxxxxxxxxxxxxxxx
"Peter Morris" wrote:
private void something()
{
try
{
}
catch
{
}
/// This is the *finally* code from this point. One may check
conditions
at
this point, but what happens here is the *finally*.
}
private void something()
{
try
{
}
catch
{
throw now Exception("Oh no it isn't!");
}
}
:-)
It's called poor programming, and one did not know what the abort
conditions
were out of the gate. It shouldn't happen that one doesn't know the abort
conditions and what to do on a try/catch, IMHO.
Catching all exception in the first place was poor programming at a higher
magnitude and if you don't catch all of them, your code is not anymore
equivallent to a finally block.
Like I said, one should know the conditions of a try/catch and the
excpetions that need to be caught or dealt with in the exception for a given
situation(s).
Just because there is a try/catch does that mean that a *finally* is needed.
The only time I have implemeted a try/catch/finally is on a SQL connection
using the USING statement to make sure the connection was checked to be
closed and close the connection if opened, because the solution was keeping
state while continiously doing background processing with a Windows Service
application as an example.
If the exception is in an ASP.Net solution, there is no need for a *finally*
as the application is not keeping state and is gone anyway.
.
- Follow-Ups:
- Re: What's finally keyword good for?
- From: Christophe Lephay
- Re: What's finally keyword good for?
- References:
- What's finally keyword good for?
- From: K Viltersten
- RE: What's finally keyword good for?
- From: Ollis
- Re: What's finally keyword good for?
- From: Peter Morris
- Re: What's finally keyword good for?
- From: Ollis
- Re: What's finally keyword good for?
- From: Christophe Lephay
- What's finally keyword good for?
- Prev by Date: Re: A good .net obfuscator
- Next by Date: Re: camelCase
- Previous by thread: Re: What's finally keyword good for?
- Next by thread: Re: What's finally keyword good for?
- Index(es):
Relevant Pages
|
Loading