In terms of which is the most efficient way of calling a cfcs... I like to
use
CreateObject(objectname,component);

Thinking about CFCs like classes in Java or C++ is natural for me, so I like
to work in that mentality.. like Hal Helms points out.

Keep in mind though, some hosting providers limit the use of this function.
cfinvoke is nice as well...

----- Original Message ----- 
From: "Ian Skinner" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Tuesday, June 10, 2003 1:24 PM
Subject: CFC Newbie Discussion.


> I'm experimenting with my first CFC.  I've written these simple example
> files.
>
> *** test.cfc ***
> <cfcomponent displayname="My First CFC" hint="A trial CFC">
> <cfset this.X = 10>
> <cfset this.Y = 15>
>
> <cfset A = 5>
> <cfset B = 3>
>
> <cffunction name="multiplyXY" access="public" returntype="numeric">
> <cfset myResult = this.X * this.Y>
> <cfreturn myResult>
> </cffunction>
>
> <cffunction name="multiplyAB" access="public" returntype="numeric">
> <cfset myResult = A * B>
> <cfreturn myResult>
> </cffunction>
> </cfcomponent>
> *** end ***
>
> *** test.cfm ***
> <cfobject name="testObj" component="test">
> <cfdump var="#testObj#">
>
> <cfset this.X = 12>
> <cfset this.Y = 24>
>
> <cfset A = 21>
> <cfset B = 32>
>
> <cfinvoke component="#testObj#" method="multiplyXY" returnvariable="joe"/>
> <cfinvoke component="#testObj#" method="multiplyAB" returnvariable="sam"/>
>
> <cfinvoke component="test" method="multiplyXY" returnvariable="joe2"/>
> <cfinvoke component="test" method="multiplyAB" returnvariable="sam2"/>
>
> <cfoutput>
> #testObj.X# * #testObj.Y# = #joe#<br>
> #testObj.X# * #testObj.Y# = #testObj.multiplyXY()#<br>
> #this.X# * #this.Y# = #this.X * this.Y#<br>
> <br>
> #sam#<br>
> #testObj.multiplyAB()#<br>
> #A * B#<br>
> <br>
> #joe2#<br>
> #sam2#<br>
> </cfoutput>
> *** end ***
>
> What I would like to discuss is the performance differences between the
> various component methods I've tested here.
>
> In the CFC code, the X and Y variables are in the "this" scope and the A
and
> B variables are in the default "variable" scope.  What are the differences
> between these practices other then the X and Y are available as properties
> of an object (obj.X and obj.Y).
>
> Then in the CFM code I accessed the component a couple different ways.  I
> first used a <cfobject> tag to "instantiate" an instance of the component
as
> a object variable "testObj".  I then accessed the methods of that instance
> with a <cfinvoke> on testObj and directly [testObj.method()].  Finally I
> just accessed the methods of the component directly with <cfinvoke>.
>
> I would like to discuss the pros and cons of these different practices and
> when one might be better then another.  Also, I remember reading about
some
> kind of scope bug involving CFC's, but since I wasn't really familiar with
> CFC's at the time, I really didn't understand what I was reading.  What
> would this be about?
>
> Thank You
>
> --------------
> Ian Skinner
> Web Programmer
> BloodSource
> Sacramento, CA
>
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. 
http://www.fusionauthority.com/ads.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to