My biggest problem with evaluate is not so much the method itself, but
rather, that majority of the time that I see it, it reprsents a core
misunderstanding of how the language can be leveraged. For instance, I see
things like this A LOT!
<cfset objValue = Evaluate("FORM." & strFieldName)
/>
Does it work? Yes. But it clearly demonstrates a misunderstanding of
scope usage:
<cfset objValue = FORM[ strFieldName ] />
Much cleaner and easier to read and one step less than the evaluate
method.
Or even when people create dynamic query names and then need to reference
them later (like in a loop):
<cfset qData = Evaluate( "qDataQuery" + index )
/>
Does it work? Yes. But could be much cleaner from using
scopes:
<cfquery
name="REQUEST.DataQuery#index#">...</cfquery>
<cfset qData = REQUEST["DataQuery" & index]
/>
In this case, not much easier to read, but feels more natural especially
if you are used to objects/scopes. So to reiterate, its
not so much that Evalute is a poor method, its that the use of it, in most
cases, is a symptom of a misunderstanding of the language.
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Brian Rinaldi
Sent: Thursday, May 18, 2006 11:05 AM
To: [email protected]
Subject: Re: [CFCDev] CFINVOKE vs. Evaluate
"Don't use evaluate() - Avoid
evaluate() unless there is no
other way to write your code (and there is almost always another way to write
your code)."A Google search only comes up with the following posts (the first being recent and the second a couple years old):
http://cfprimer.blogspot.com/2005/03/avoid-evaluate.html
http://www.sitepoint.com/blogs/2004/02/19/running-performance-metrics-on-coldfusion-functions-and-operators/
An MXNA search comes up with some more recent posts:
http://www.succor.co.uk/index.cfm/2006/4/13/Avoid-evaluate-always
http://www.blogoffusion.com/index.cfm/2006/4/18/Structure-style-evaluation-rocks
However, nobody seems to offer specific metrics (except for one that came to the conclusion that the differences were minimal). Let me be clear, I am not arguing that this isn't a completely valid best practice - I am sure at some point it was based upon some documented metrics, but it would be nice to see them.
- Brian Rinaldi
blog: http://www.remotesynthesis.com/blog
ColdFusion Open Source List: http://www.remotesynthesis.com/cfopensourcelist
Boston CFUG - http://www.bostoncfug.org
From: "Nick Tong - TalkWebSolutions.co.uk" <[EMAIL PROTECTED]>
Sent: Thursday, May 18, 2006 10:49 AM
To: [email protected]
Subject: Re: [CFCDev] CFINVOKE vs. Evaluate
On 18/05/06, Peter Bell <[EMAIL PROTECTED]>wrote:
> So, would cf invoke actually be any faster?
I think this can depend on if you have initiated the object into memory i.e.
in this case then i believe it is faster
--
Nick Tong
web: http://talkwebsolutions.co.uk
blog: http://succor.co.uk
shorturls: http://wapurl.co.uk
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).
An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).
An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
