Subject | Re: [IBO] recordcount.. more used than i thought |
---|---|
Author | Dennis Fantoni |
Post date | 2000-11-29T11:45:56Z |
I stopped using recordcount when i moved from singleuser to multiuser
systems back in the D1 days. Unfortunately other people have been on this
project from time to time - and i use components that other people have
written. They obviously didn't loose the bad habit.
The problem is, that i still have to convert lots of old systems, where
other developers seem to like FOR better than while. I allways try to
rewrite FOR into while loops. I think it is less error prone in general. The
recordcount usage feels "natural" wtih a for loop so i found a lot of for
n:= 0 to recordcount do begin's . Even tho recordcount is a bad thing when
trying to figure out the number of records a query will return (and i
agree - never used it that way) , we still have lots of old code with
recordcount in it. So it would be a big help for future users of IBO if the
recordcount property returned the "correct" number. It will make those
programs run better than they do now ;-) A good example is a routine i found
here, that decides if a table is broken and needs to be reimported from a
textfile. the check was with recordcount. Guess what happens if the code
runs ;-) KaZoom, goodbye tabledata and hello default data...
Even if recordcount gets fixed, i think there should be a warning about it's
use in the conversion guide. I never would have expected to find 60+
recordcount usages in this program. I knew for sure that i only have put in
one or two, and i've never stumbled upon any by accident (as far as i
recall). Most of them were hidden in dataaware components, addon modules
like exporting and importing and other stuff i don't see in my normal line
of work. Most of them shouldn't be there in the first place, but they are,
and i'm sure this project might not be especially special.
In short. I agree that recordcount is a bad thing, but i'm also sure that we
have some tidying up to do, cause back in the D1 and paradox table days,
when programs were running as singleuser database systems - recordcount was
a very fast way to get the size of a table. There is old code out there...
and old habits.. older than you would imagine.. The codebase for this
project is 3 months older than Delphi (was coded originally with the D1
beta). I find odd things in there from time to time ;-)
Regards
Dennis Fantoni
dennis@...
C/S Developer ( Delphi & Interbase ) at Danasoft A/S -
http://www.danasoft.dk
systems back in the D1 days. Unfortunately other people have been on this
project from time to time - and i use components that other people have
written. They obviously didn't loose the bad habit.
The problem is, that i still have to convert lots of old systems, where
other developers seem to like FOR better than while. I allways try to
rewrite FOR into while loops. I think it is less error prone in general. The
recordcount usage feels "natural" wtih a for loop so i found a lot of for
n:= 0 to recordcount do begin's . Even tho recordcount is a bad thing when
trying to figure out the number of records a query will return (and i
agree - never used it that way) , we still have lots of old code with
recordcount in it. So it would be a big help for future users of IBO if the
recordcount property returned the "correct" number. It will make those
programs run better than they do now ;-) A good example is a routine i found
here, that decides if a table is broken and needs to be reimported from a
textfile. the check was with recordcount. Guess what happens if the code
runs ;-) KaZoom, goodbye tabledata and hello default data...
Even if recordcount gets fixed, i think there should be a warning about it's
use in the conversion guide. I never would have expected to find 60+
recordcount usages in this program. I knew for sure that i only have put in
one or two, and i've never stumbled upon any by accident (as far as i
recall). Most of them were hidden in dataaware components, addon modules
like exporting and importing and other stuff i don't see in my normal line
of work. Most of them shouldn't be there in the first place, but they are,
and i'm sure this project might not be especially special.
In short. I agree that recordcount is a bad thing, but i'm also sure that we
have some tidying up to do, cause back in the D1 and paradox table days,
when programs were running as singleuser database systems - recordcount was
a very fast way to get the size of a table. There is old code out there...
and old habits.. older than you would imagine.. The codebase for this
project is 3 months older than Delphi (was coded originally with the D1
beta). I find odd things in there from time to time ;-)
Regards
Dennis Fantoni
dennis@...
C/S Developer ( Delphi & Interbase ) at Danasoft A/S -
http://www.danasoft.dk
----- Original Message -----
From: "Lucas Franzen" <luc@...>
To: <IBObjects@egroups.com>
Sent: Wednesday, November 29, 2000 12:22 PM
Subject: Re: [IBO] recordcount.. more used than i thought
>
>
> Dennis Fantoni schrieb:
> >
> > I searched the entire project for use of recordcount. To my surprise the
> > former developer has used it quite consistently in several different
> > situations. 63 occourences in total. I'll have to deal with all of them
> > manually.
>
> Using RecordCount to step through all records of a query is nonsense
> anyway; using while not EOF is much more efficient. (using RecordCOunt
> implies that ALL Records have to be fetched first; you can easily test
> this: open up a table in IBO_WISQL; records are shown pretty quick - now
> hit the RecordCount-button and if there are lots of records you'll
> notice that it might take some time to get the result since all records
> have to be fetched to be counted)