[thelist] ASP Recordsets, was re: SQL: using GROUP BY and COUNT

Paul Cowan evolt at funkwit.com
Mon Aug 19 19:45:01 CDT 2002


rudy (don't take your love to town) wrote:
> > if you would like to compare languages, mine is coldfusion, and we are
> > taught not to dump stuff into arrays if there's no good
> > reason to do so

so then Chris W. Parker wrote:
> must be different in asp. i'd like to hear from someone else.

Meh. Well, as an ASP head, the common wisdom is certainly to do:

<%
    arrData = rstSomethingOrOther.GetRows()
    for i = lbound(arrData, 2) to ubound(arrData, 2)
        response.write "First Name: " & arrData(0, i)
        response.write "Surname: " & arrData(1, i)
    next
%>

for performance reasons, because it's much faster. Indeed, even if you
want to keep using a recordset, you should supposedly do:

<%
    do unti (rstData.eof)
        response.write "First Name: " & rstData(0)
        response.write "Surname: " & rstData(1)
    ... etc ...
%>

Because it's also quicker. And it *is* quicker, substantially
(particularly example #1).

However, I say this is a load of old cobbler's. I mean, really. You reach
a point where you have to say "yes, I KNOW it's faster, but I care about
readability and maintainability too, dammit."

How much easier is it to say:
<%
    do unti (rstData.eof)
        response.write "First Name: " & rstData("FirstName")
        response.write "Surname: " & rstData("Surname")
    ... etc ...
%>
???

Sure, you can define constants like FIELD_INDEX_FIRST_NAME = 0 for the
first two cases, but really, I think you're pushing fecal matter up
a hill with a forked stick on this one. Indexes WILL change, and
there'll be some piece of code somewhere that will break. Why
not just make it easier on yourself?

Sure, if there is a hyper-critical piece of code which NEEDS to be
optimised for performance, go nuts: but for everyday, called-semi-
frequently-or-lesscode, frankly I think you have to weigh up "cost
of maintenance" vs. "cost of just throwing more hardware at it".

And your sanity.

My 2 cents,

Paul (aka "Captain Tradeoff")





More information about the thelist mailing list