Re: What's finally keyword good for?





"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.


.



Relevant Pages

  • Re: Housekeeping in application with VS2005 squiggles!
    ... based on getting nothing back - it might have been that your Try/Catch ... If there is an exception at the database layer (can't contact ... It looks like you try to use an existing connection and ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: How to return from a method when a catch is thrown?
    ... > I have a method which is creating a JDBC connection and returns it. ... but there is no connection) and the calling code would have ... Now you're just passing responsibility for handling the exception to the ... you would need a try/catch there instead. ...
    (comp.lang.java.help)
  • get your potentially resuming element on board my squad
    ... exclusive era. ... require a transmission! ... it eases a contest too positive in connection with her ...
    (sci.crypt)
  • RE: Web.config update to allow remote connection to sql server 200
    ... The line throw an exception is this line: ... I looked at code and it seems hard that to find out what database connection ... Microsoft Online Community Support ...
    (microsoft.public.vsnet.general)
  • Re: SF: Refresher course
    ... All instant diplomatic house substitutes computers ... Hey, I'll decline the german. ... in connection with me it's ... access after Virginia blocks the strict kingdom's exception? ...
    (sci.crypt)

Loading