Myles

You've obviously got to much spare time, So I'll ask another one

I'm continously amazed how delphi code uses methods repeatedly, there must
be some reason
especially for assigned checks

like

  if Query.FindField('col1') <> nil then Query.FindField('col1').AsString :=
'blah'

  not

var
 f: TField;

 f :=  Query.FindField('col1');
 if assigned(f) then f.AsString := 'blah';

which is more efficient for the allocation of 1 pointer
or should we just

  try
    Query.FindField('col1').AsString := 'blah'
  except
  end

I agree on the debugging thing, its a pain it would be good if you could
ingore
handled exceptions per block of code not globally, I'd use try/excepts more
It looks like im into traversing object properties still :-)

Neven


----- Original Message -----
From: "Myles Penlington" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Friday, November 02, 2001 3:22 PM
Subject: RE: [DUG]: Best practice - To except or not


> Assigned() generates identical code to <> nil, and not Assigned()
generates
> identical code to = nil.
> So take your pick.
>
> Myself - I prefer to use Assigned() - treat it as an inlined compiler
> function - same applies to Pred(), Succ(), Inc() and Dec().
>
> What really gets to me with Succ() and Pred() (Sometimes!) is that for
> enumeration types they do not wrap around - because they generate
identical
> code to Inc() and Dec()!!!!!
>
> Myles.
>
>
> -----Original Message-----
> From: Neven MacEwan [mailto:[EMAIL PROTECTED]]
> Sent: Friday, 2 November 2001 3:05 p.m.
> To: Multiple recipients of list delphi
> Subject: Re: [DUG]: Best practice - To except or not
>
>
> Paul
>
> Thanks for the help, It would be great it assigned() worked wouldn't it
> Maybe there is a suggestion for borland in there
>
> This leads to another question, is 'assigned()' pref to '<> nil'?, is
> pred(count) better thasn Count-1?
>
> Actually thats inc(1) questions, or was that 1+1 questions
>
> It must be friday
>
> Neven
>
>
> ----- Original Message -----
> From: "Paul Heinz" <[EMAIL PROTECTED]>
> To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
> Sent: Friday, November 02, 2001 2:53 PM
> Subject: RE: [DUG]: Best practice - To except or not
>
>
> > Sandeep wrote:
> >
> > > > > This is better
> > > > >
> > > > >   if Assigned (Datasource.DataSet.Connection)
> > > > >   then Result := Datasource.DataSet.Connection;
> > > >
> > > >
> > > > if Datasource.Dataset is nil won't this raise
> > > > an exception?
> > >
> > > Conditon evaluates to false in that case
> >
> > In Delphi 5, you get an access violation since Assigned only tests the
> final
> > deref not the early one. Maybe it's changed in Delphi 6.
> >
> > TTFN,
> >   Paul.
> >
> >
>
> --------------------------------------------------------------------------
> -
> >     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> >                   Website: http://www.delphi.org.nz
> > To UnSub, send email to: [EMAIL PROTECTED]
> > with body of "unsubscribe delphi"
> > Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
> >
>
> --------------------------------------------------------------------------
-
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
> --------------------------------------------------------------------------
-
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
>

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to