Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Delphi > Re: Has a TStri...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 13 Topic 1081 of 1135
Post > Topic >>

Re: Has a TStringlist been created

by erewhon@[EMAIL PROTECTED] (J French) Oct 13, 2006 at 08:09 AM

On Fri, 13 Oct 2006 19:58:22 +1300, Nicholas Sherlock
<N.sherlock@[EMAIL PROTECTED]
> wrote:

>J French wrote:
>> Further to Rob's points, you really need to set up a Flag of some sort
>> to indicate whether an object has been created
>> 
>> You can rely on the instance pointer being Nil, provided you make darn
>> sure that it starts life off as Nil and you FreeAndNil it rigorously
>> - but the hassle, and the problems when one makes a mistake, far
>> outweigh the benefit of saving one explicit variable

>I don't get it. What work do you avoid, by using an explicit variable 
>instead of simply nilling pointers that don't go anywhere useful?

Well, I used to use the:   If Assigned( SomeObj ) Then   approach
- but I found that I was having to make darn sure that I was doing
SomeObj := Nil   at the begining of the routine because local
variables are not cleared when put on the Stack (except when they are
<g> )

I found that the code was getting less and less readable as I was
using the 4 byte object reference as a sort of substitute flag.

In my case it was generally a matter of creating a series of objects
and backing out if I ran into problems.  Since backing out does not
happen that often, I found that I was building obscurity into little
tested code.

I think that nowadays I would use a nested Try Finally construct, with
Exit used to guarantee destruction of things that needed to be
destroyed.

While writing code, it is blatantly clear what everything really
means, it is just a problem six months later, getting ones head around
the subtle implications - hence my recommendatito write blatantly
obvious code.
 




 13 Posts in Topic:
Has a TStringlist been created
Rich <taxidermist@[EMA  2006-10-12 21:36:53 
Re: Has a TStringlist been created
Rob Kennedy <me3@[EMAI  2006-10-13 01:11:39 
Re: Has a TStringlist been created
erewhon@[EMAIL PROTECTED]  2006-10-13 06:58:58 
Re: Has a TStringlist been created
Nicholas Sherlock <N.s  2006-10-13 19:58:22 
Re: Has a TStringlist been created
erewhon@[EMAIL PROTECTED]  2006-10-13 08:09:50 
Re: Has a TStringlist been created
Jamie <jamie_ka1lpa_no  2006-10-13 14:08:16 
Re: Has a TStringlist been created
erewhon@[EMAIL PROTECTED]  2006-10-14 08:08:16 
Re: Has a TStringlist been created
Nicholas Sherlock <N.s  2006-10-14 07:20:43 
Re: Has a TStringlist been created
erewhon@[EMAIL PROTECTED]  2006-10-14 08:12:43 
Re: Has a TStringlist been created
Nicholas Sherlock <N.s  2006-10-15 12:16:54 
Re: Has a TStringlist been created
erewhon@[EMAIL PROTECTED]  2006-10-15 08:18:27 
Re: Has a TStringlist been created
Jamie <jamie_ka1lpa_no  2006-10-13 14:00:11 
Re: Has a TStringlist been created
Jamie <jamie_ka1lpa_no  2006-10-28 23:23:17 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Sep 7 23:03:05 CDT 2008.