> is the following code ok? or should I give each it's own try..finally?

strictly speaking, yes - although shortcuts are common in an aid to
readability when there is little chance of failure as you suggest. All
depends on how comfortable you are with taking that risk.

another very cool approach is to use interfaces and their in-built reference
counting to automatically free the local object var when it goes out of
scope.

see www.madrigal.com.au

dang - that site is down. I can probably dig up Malcolm Grove's article
somewhere if needed.

hth
Steve

> 
> --
> 
> changes := TStringList.create;
> issues := TIssuesList.create;
> terrorists := THardToFind.create;
> try
> 
> // stuff is done, planes flown.  That type of things.
> 
> finally
>   terrorists.free;
>   issues.free;
>   changes.free;
> end;
> 
> --
> 
> I mean what could go wrong in the TStringList.create constructor for
> example?  It's not like there should be anything much in 
> there that could go
> wrong anyway?  Because if it does except the destructor will 
> be immediately
> called - learnt that one the hard way many years ago.  As a 
> general rule of
> thumb I don't put anything significant in a constructor for 
> my own classes -
> that's what init or setup methods are for.
> 
> For the record I've never done it this way, I've always given 
> each their own
> try..finally.
> 
> Thoughts anyone?
> 
> 
> 
> Nahum Wild
> Software Innovator & Process Consultant
> IFE
> PayGlobal
> 
> _______________________________________________
> Delphi mailing list
> [EMAIL PROTECTED]
> http://ns3.123.co.nz/mailman/listinfo/delphi
> 
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.610 / Virus Database: 390 - Release Date: 3/03/2004
>  
> 
_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to