I think block 1 is optimal in this case. In [I assume] the most common case, that 
myQuery.RecordCount is GT 0, it will result in one less string assignment, thus better 
performance. Also, this is probably not a situation where your cfif might in the 
future expand into a cfif/cfelseif/cfelseif/... block. If that were the case, then 
block 2 might be easier to maintain.

My 2¢...
Mike Mertsock
Alfred University Web Team

>I was mulling this over last night.... 
>
>Should there be any preference between the following two examples of
>code?
>
>
><!---  Code Block 1 --->
><cfif myQuery.RecordCount>
>       <cfset theName = myQuery.FIRST_NAME & " " & myQuery.LAST_NAME>
><cfelse>
>       <cfset theName = "Undefined">
></cfif>
>
>
><!--- Code Block 2 --->
><cfset theName = "Undefined">
><cfif myQuery.RecordCount>
>       <cfset theName = myQuery.FIRST_NAME & " " & myQuery.LAST_NAME>
></cfif>
>
>
>I prefer code block 2 as it is one less line, but are there any
>technical merits between the two
>
>Does it matter? Should I get out more?  It can be grim up north you know
>:-)
>
>DC
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
http://www.cfhosting.com

Reply via email to