[thelist] Cold Fusion: Style Tips?

rudy limeback r937 at interlog.com
Sun, 23 Jan 2000 09:13:41 -0500


hi frank, hi jeff,

> Do I put my queries before the HTML starts, or do I include it in the
<html>

as far as the html is concerned, it doesn't matter

most people put it at the top -- maybe they like the idea that all that
white space ahead of the first html statement will increase the chance that
somebody looking at the source code will think it has been magically
hidden!


>my approach with queries and other cfml code is to treat it like i would
>javascript.  everything that i need to define before writing out html goes
>above the doctype declaration, complete with all the logic necessary to
>establish all the values and variables i'll need later on in the template.

i learned javascript before cold fusion too, and so naturally put the
cfquery up at the top, where it's handy for documentation purposes

where javascript and cold fusion differ is that a javascript function
doesn't execute until it's called, whereas a cfquery is executed right
there, wherever it sits, as the page is scanned sequentially by the cold
fusion server (well, sequentially except for cfloops)

i had thought that perhaps a cfquery doesn't "execute" until it's called in
a cfoutput somewhere, but no, it gets executed inline

not that it matters all that much where in the source code it is, if you
only execute it once

<tip type=cf performance>
be careful, though, and try hard (try *very* hard) not to execute a query,
test something in the result set that it returns, then execute another
query based on the test -- going back and forth from the cf logic to the
database more than the minimum one time can profoundly impact the
performance of the page
</tip>

___________________
rudy limeback
http://www.interlog.com/~r937/
http://evolt.org/