Stick with whatever code construct is the most semantically descriptive and best encapsulated and you will rarely go wrong. Making choices about code to save a few milliseconds is typically a path to badness overall.
Tony Weeg wrote:
----------------------------------------------------------hola peeps.
i have a cfc, that simply takes an integer that represents a heading, and turn that into a value that i display based on the return.
i put the cfc in the session scope:
<cfset session['COG'] = createObject("component","cfc.cogToDirection") />
and then just hit it like this...
#session['COG'].COGToDirection(getThis.COG[i])#
and display all in the same line.
now, in my debugging output i see 0ms. but i know that there is no such thing. there are milliseconds attached, im sure, and enough of those, well, you know... equal a second. regardless... do you think, as a preference, that i would be better off with a simple cfswitch/cfcase section of code that does this, rather than hit the cfc?
thanks. tw
<cfcomponent displayName="cogToDirection" hint="Turn COG integer to a compass direction">
<cffunction name="COGToDirection" access="public" output="1" returntype="string"> <cfargument name="cog" type="numeric" required="true"/> <cfset request.cogValue = (arguments.cog + 22.5) \ 45>
<cfswitch expression="#request.cogValue#">
<cfcase value="0">
<cfset strHeading = "N">
</cfcase>
<cfcase value="1">
<cfset strHeading = "NE">
</cfcase>
<cfcase value="2">
<cfset strHeading = "E">
</cfcase>
<cfcase value="3">
<cfset strHeading = "SE">
</cfcase>
<cfcase value="4">
<cfset strHeading = "S">
</cfcase>
<cfcase value="5">
<cfset strHeading = "SW">
</cfcase>
<cfcase value="6">
<cfset strHeading = "W">
</cfcase>
<cfcase value="&">
<cfset strHeading = "NW">
</cfcase>
<cfcase value="8">
<cfset strHeading = "N">
</cfcase>
<cfdefaultcase>
<cfset strHeading = "N">
</cfdefaultcase>
</cfswitch>
<cfreturn strHeading>
</cffunction>
</cfcomponent>
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
