Also
> The speed issue?  About the same difference as <cfif vs. <cfswitch...

The main reason I would use switch over if is to make it easer to read, and
easier to maintain.  That it is faster is just a bonus.  Thats like saying:

<CFSET var1 = "this">
<CFSET var2 = "that">
<CFSET var3 = "foo">
<CFSET var4 = "bar">

is better than:

<CFSCRIPT>
        var1 = "this";
        var2 = "that";
        var3 = "foo";
        var4 = "bar";
</CFSCRIPT>

or that in this case it wouldn't make the most sense to use:

<CFSCRIPT>
        var = arrayNew(4);
        var[1] = "this";
        var[2] = "that";
        var[3] = "foo";
        var[4] = "bar";
</CFSCRIPT>

The third is both faster and easier to read as far as I am concerned.  Now I
hear people say that the amount of time you save is so small that it's not
even worth worrying about, well the way I see it is if you use ALL the
fastest and most optimized code you can, then it will add up, and be
noticeable.  Even if it is not noticeable to a single user, it can also help
reduce your processor load on heavy hit sites.  When requests are over
quicker, more requests can be processed faster and so on.  Also we shouldn't
cater coding standards to the beginner, we should train and assist the
beginner to the standard.

My 0.02

Tim Heald
ACP/CCFD :)
Application Development
www.schoollink.net

> -----Original Message-----
> From: Timothy Heald [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 09, 2002 5:56 PM
> To: CF-Talk
> Subject: RE: Form.FIELDNAME - error!!!!
>
>
> I would think that best practices in this case would be to allow the DB to
> do it's job.  I know on SQL Server I do:
>
> <cfquery datasource="#dsn#" name="getItems">
>      select cFirstName + ' ' + cLastName as cFullName
>      from tablename
> </cfquery>
>
> I think that may even be ansi SQL and should be availabe to most rdbms.
>
> Tim Heald
> ACP/CCFD :)
> Application Development
> www.schoollink.net
>
> > -----Original Message-----
> > From: Paul Giesenhagen [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, May 09, 2002 5:48 PM
> > To: CF-Talk
> > Subject: Re: Form.FIELDNAME - error!!!!
> >
> >
> > I guess my example was:
> >
> > <cfquery datasource="dsn" name="getitems">
> >     select first_name, last_name
> >     from tablename
> > </cfquery>
> >
> > <cfoutput>
> >     <cfloop query="getitems">
> >         <cfset variables.full_name = "#getitems.first_name#
> > #getitems.last_name#">
> >         .....OR .....
> >         <cfset variables.first_name = "#getitems.first_name#">
> >         .... AS opposed to...
> >         <cfset variables.first_name = getitems.first_name>
> >
> >     </cfloop>
> > </cfoutput>
> >
> > Now, I will say that I used to not put the #'s, but it made it
> easier (not
> > cleaner) for new cf users we have to read the code, it told them that
> > #something# was a variable and not explicit..
> >
> > This is definately nit-picky ...  But I guess I am on an island :)!
> >
> > The speed issue?  About the same difference as <cfif vs. <cfswitch...
> >
> > Paul Giesenhagen
> > QuillDesign
> > http://www.quilldesign.com
> > SiteDirector Commerce Builder
> >
> >
> >
> > > I vote for Reuben on this. I disagree with your argument.
> While you want
> > > periods in a book. You. Don't. Want. Too. Many. Of. Them.
> > People new to CF
> > > often over use pound signs. So we are encouraged to learn when
> > they're not
> > > needed and then not use them. Thus Reuben's and my preference for not
> > using
> > > them when not needed. That doesn't mean it's the only right
> way, but it
> > > certainly is one of them.
> > >
> > > I don't understand your example: <cfset variables.my_var =
> > "query.column">
> > > It's obvious that you're setting your variable to the two words
> > separated
> > by
> > > a period.
> > >
> > > I also write things like <cfif MyQuery.RecordCount> and I
> think this is
> > > easier to read (for me anyway) than <cfif MyQuery.RecordCount GT 0>.
> > >
> > > Matt
> > >
> > > ----- Original Message -----
> > > From: "Paul Giesenhagen" <[EMAIL PROTECTED]>
> > > To: "CF-Talk" <[EMAIL PROTECTED]>
> > > Sent: Friday, May 10, 2002 8:53 AM
> > > Subject: Re: Form.FIELDNAME - error!!!!
> > >
> > >
> > > > I understand your point, but it is like saying periods
> > clutter up pages
> > in
> > > a
> > > > book.
> > > >
> > > > If you have:
> > > >
> > > > <cfset variables.my_var = "#query.column#">
> > > > That tells me that there is a variable being set and it is a string
> > > >
> > > > <cfset variables.my_var = "query.column">
> > > >
> > > > Am I setting my variable to the two words seperated by a period,
> > > > query.column? or to a variable query.column?
> > > >
> > > > To each his own, but it makes more sense to me to see those
> pounds on
> > the
> > > > right hand side ..  Plus reading a book with periods is
> easier too :)
> > > >
> > > > Paul Giesenhagen
> > > > QuillDesign
> > > > http://www.quilldesign.com
> > > > SiteDirector Commerce Builder
> > > >
> > > >
> > > >
> > > >
> > > > > I think that the # on the right side of the set operand is
> > redundant.
> > > > >
> > > > > <CFSET my_var = #another_var#>
> > > > >
> > > > > or
> > > > >
> > > > > <CFSET my_var = another_var>
> > > > >
> > > > > There is only one thing for *another_var* to be: a
> variable.  If you
> > > > wanted
> > > > > my_var to hold the string "another_var" you should quote the right
> > hand
> > > > > side:
> > > > >
> > > > > <CFSET my_var = "another_var">
> > > > >
> > > > > So my .02 is that pounds just clutter up your statement.
> > > > >
> > > > > Reuben Poon
> > > > >
> > > > >
> > > > > -----Original Message-----
> > > > > From: Paul Giesenhagen [mailto:[EMAIL PROTECTED]]
> > > > > Sent: Thursday, May 09, 2002 1:35 PM
> > > > > To: CF-Talk
> > > > > Subject: Re: Form.FIELDNAME - error!!!!
> > > > > Importance: Low
> > > > >
> > > > >
> > > > > Tim,
> > > > >
> > > > > I wouldn't call that bad practice, It should actually be
> called good
> > > > > practice (at least in my book).  You are setting a variable
> > and the ##
> > > > > around the variable show that it is a variable, makes for easier
> > > reading.
> > > > > Now, ## on the set side would be considered bad practice.
> > > > >
> > > > > my .02
> > > > >
> > > > > Paul Giesenhagen
> > > > > QuillDesign
> > > > > http://www.quilldesign.com
> > > > > SiteDirector Commerce Builder
> > > > >
> > > > >
> > > > > > Not sure if this is an error or just a bad practice,
> but you don't
> > > need
> > > > > the
> > > > > > # signs in your variable declaration (cfset)
> > > > > >
> > > > > > <CFSET var = ListGetAt(Form.FIELDNAMES, i)>
> > > > > >
> > > > > > works just fine.  Also you don't need to generate that
> var at all
> > you
> > > > can
> > > > > > just do a list loop like this:
> > > > > >
> > > > > > <CFLOOP list="#form.fieldnames#" index="formField">
> > > > > > #formField# = #evaluate(formField)#
> > > > > > <CFLOOP>
> > > > > >
> > > > > > Tim Heald
> > > > > > ACP/CCFD :)
> > > > > > Application Development
> > > > > > www.schoollink.net
> > > > > >
> > > > > > > -----Original Message-----
> > > > > > > From: Chakka, Sudheer [mailto:[EMAIL PROTECTED]]
> > > > > > > Sent: Thursday, May 09, 2002 4:16 PM
> > > > > > > To: CF-Talk
> > > > > > > Subject: Form.FIELDNAME - error!!!!
> > > > > > >
> > > > > > >
> > > > > > > Hi,
> > > > > > >
> > > > > > >  Can any one tell me what is the mistake in
> > > > > > >
> > > > > > > <CFLOOP FROM="1" TO="#ListLen(FORM.FIELDNAMES)#" STEP="1"
> > INDEX="i">
> > > > > > > <CFSET var = #ListGetAt(Form.FIELDNAMES, i)#>
> > > > > > > #ListGetAt(Form.FIELDNAMES, i)# = #Evaluate(var)#
> > > > > > > <BR>
> > > > > > > </CFLOOP>
> > > > > > >
> > > > > > >
> > > > > > > I am getting the following error:
> > > > > > >
> > > > > > > An error occurred while evaluating the expression:
> > > > > > > "#ListLen(FORM.FIELDNAMES)#"
> > > > > > >
> > > > > > >
> > > > > > >  Any help on this is appreciated.
> > > > > > >
> > > > > > > thanks,
> > > > > > > Sudheer Chakka.
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > >
> >
> 
______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to