Hey Dave,
Just a quick note to clarify... the end result of any call to a CFC is an
instance of an object.
Whether you're using cfinvoke, cfobject, or createObject(), you're still
creating an instance of an object that can be used to store data and execute
methods.
The difference is how that object works. Some objects are stateless (i.e.
they don't store data and they generally have a minimal lifespan), and
others are stateful (i.e. they do store data and they're the kind of object
you'd keep in the application or session scope). If you have something like
math.cfc, and it has a method called addition(), it might work like this:
<cfset num1 = 10>
<cfset num2 = 11>
<cfinvoke component="math" method="addition" number1="#num1#"
number2="#num2" returnvariable="added" />
Internally, addition has this to say:
<cffunction name="addition">
<cfargument name="number1" type="numeric" />
<cfargument name="number2" type="numeric" />
<cfreturn arguments.number1+arguments.number2 />
</cffunction>
That's a method where CFMX would create the object, do the calculation,
return the data, and then destroy the object... but internally CFMX still
has an instance of math.cfc.
That process is less efficient under load because of the need to read the
file and operate on it before executing the method in question, so often we
put instances of things in the application scope and session scope... but,
functionally, it's still doing the same thing. Even if it's in the
application scope on a shared server, unless there's confidential data (bad,
bad idea) or a danger that just reading the info might cause, it's not a bad
thing really.
The CFINVOKE tag above is functionally exactly the same as this:
<cfset added=createObject{"component","math").addition(num1,num2)>
For any practical purpose, that is identical to cfinvoke (except it's
shorter hehe). Because the variable named "added" ends up containing
whatever addition() returns, it's a numeric value. You don't end up with a
live instance of an object unless your <cfreturn /> returns an object...
like this:
<cfreturn this />
or
<cfreturn createObject("component","someOtherObject").init(num1,num2)>
You just need to be careful what you expose by caching... and do everything
you can to get a dedicated server. ;)
Laterz,
J
On 6/11/05, dave <[EMAIL PROTECTED]> wrote:
>
> well I was thinking that on a shared server it probably wouldn't be a real
> good idea to create an object out of it (just in case they take that way for
> security) and the dreamweaver one doesn't add it correctly, was just curious
> what ppl are using, since I see quite a lot of diff techniques.
>
> ~Dave the disruptor~
> "A criminal is a person with predatory instincts who has not sufficient
> capital to form a corporation."
>
> ----------------------------------------
> From: "James Holmes" <[EMAIL PROTECTED]>
> Sent: Saturday, June 11, 2005 10:55 PM
> To: CF-Talk <[email protected]>
> Subject: RE: best way to invoke a cfc
>
> On a shared server, it's important to ensure that a unique name is used.
> If you have a mapping or a custom tag path, putting a unique directory
> name in the calling path and then using the dotted notation (e.g.
> myuniquename.somecfc) helps. If not, you have to rely on the default
> searching mechanism and hope it gets the right one, so prefacing the CFC
> filename with your account name may help (e.g.
> myaccountname_somecfc.cfc).
>
> As for DreamWeaver, you could cache the cfc in the application scope, if
> that's appropriate, so that it is only instantiated once when you change
> it (but then when you do change it you have to manually delete it from
> the application scope again). Of course this has implications on a
> shared server when the code goes live, in that anyone on that server has
> access to your application scope if they want it.
>
> -----Original Message-----
> From: dave [mailto:[EMAIL PROTECTED]
> Sent: Sunday, 12 June 2005 8:19
> To: CF-Talk
> Subject: best way to invoke a cfc
>
> is see a lot of ppl on here using different ways to invoke a cfc, any
> best practices? (on a shared server)
>
> the one thing i am really tired of is having the files on a local dev
> puter and having the cfc's to be called with the live settings and dw
> choking for a few minutes while it looks for component (while in code
> view), anyway around that that's practical?
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:209247
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54