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 > Borland Delphi > Re: How To Chec...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 17 Topic 3709 of 3940
Post > Topic >>

Re: How To Check if an object is created (instantiated)?

by "Rudy Velthuis" <newsgroups@[EMAIL PROTECTED] > Apr 27, 2008 at 08:46 PM

Danny Strümpel wrote:

> > > You better always use the FreeAndNil() routine instead of just
> > > Free(). 
> > 
> > I don't like FreeAndNil. It gives the user the, often false, notion
> > that he only has to check with Assigned. But FreeAndNil can only nil
> > the reference passed to it, it won't nil out any other references
> > that may still exist to the freed object.
> 
> I'm not sure if I understand you correctly. In the OPs question he's
> passing exactly 1 reference to the function.

Who cares? The routine should not FreeAndNil anything anyway, right? 

I just mentioned that the recommended use of FreeAndNil is generally
bad advice. Code should be designed thus that it should not be
necessary to set used objects to nil at all.

> > If you properly design your code, you'll find that you'll never need
> > FreeAndNil, nor a test for the validity of an object (especially
> > since such tests are useless anyway). Now how does one write code
> > properly, so that this won't happen? That is probably enough
> > material for many articles, or a good book. <g>
> 
> These tests might be useless in the majority of cases, but especially
> if you use a global variable or a class field, that is created and
> freed in several methods at runtime (for whatever reason)

That is what I meant: you don't do this in a good design.
-- 
Rudy Velthuis        http://rvelthuis.de

"Humor is always based on a modi*** of truth. Have you ever heard 
 a joke about a father-in-law?" -- Dick Clark
 




 17 Posts in Topic:
How To Check if an object is created (instantiated)?
mohamad@[EMAIL PROTECTED]  2008-04-26 07:47:33 
Re: How To Check if an object is created (instantiated)?
Jim P <Jim_P@[EMAIL PR  2008-04-26 11:37:13 
Re: How To Check if an object is created (instantiated)?
Locke <jlocke@[EMAIL P  2008-04-26 20:47:02 
Re: How To Check if an object is created (instantiated)?
=?ISO-8859-1?Q?Danny_Str=  2008-04-26 23:00:50 
Re: How To Check if an object is created (instantiated)?
"Rudy Velthuis"  2008-04-26 23:05:30 
Re: How To Check if an object is created (instantiated)?
=?ISO-8859-1?Q?Danny_Str=  2008-04-27 13:46:55 
Re: How To Check if an object is created (instantiated)?
"Rudy Velthuis"  2008-04-27 20:46:03 
Re: How To Check if an object is created (instantiated)?
"Rudy Velthuis"  2008-04-26 22:53:00 
Re: How To Check if an object is created (instantiated)?
"alanglloyd@[EMAIL P  2008-04-26 14:05:39 
Re: How To Check if an object is created (instantiated)?
=?UTF-8?B?RGFubnkgU3Ryw7x  2008-04-26 23:22:04 
Re: How To Check if an object is created (instantiated)?
Jamie <jamie_ka1lpa_no  2008-04-26 18:56:13 
Re: How To Check if an object is created (instantiated)?
"Rudy Velthuis"  2008-04-26 23:11:32 
Re: How To Check if an object is created (instantiated)?
=?ISO-8859-1?Q?Danny_Str=  2008-04-26 23:17:02 
Re: How To Check if an object is created (instantiated)?
"Rudy Velthuis"  2008-04-26 23:00:22 
Re: How To Check if an object is created (instantiated)?
=?ISO-8859-1?Q?Danny_Str=  2008-04-27 13:31:09 
Re: How To Check if an object is created (instantiated)?
"Rudy Velthuis"  2008-04-27 20:48:58 
Re: How To Check if an object is created (instantiated)?
"Rudy Velthuis"  2008-04-26 22:46:30 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Mon Oct 6 15:39:09 CDT 2008.