Re: best way to invoke a cfc

2005-06-12 Thread Jared Rypka-Hauer - CMG, LLC
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 cf-talk@houseoffusion.com
 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


Re: best way to invoke a cfc

2005-06-12 Thread dave
Thanks Jared,

 the reason I asked is I am back to working on a friends site that I haven't 
messed with for awhile and I was creating the cfc objects in the 
Application.cfm with cfobject name=getNewestListings 
component=cfc.newListings.

 and I was thinking that if at some point the host disables cfobject then I 
would be f*cked, it works well but maybe I should be changing this one now.

~Dave the disruptor~
A criminal is a person with predatory instincts who has not sufficient capital 
to form a corporation. 


From: Jared Rypka-Hauer - CMG, LLC [EMAIL PROTECTED]
Sent: Sunday, June 12, 2005 6:43 AM
To: CF-Talk cf-talk@houseoffusion.com
Subject: Re: best way to invoke a cfc 

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:

number2=#num2 returnvariable=added /

Internally, addition has this to say:

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:

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  returns an object... 
like this:

or

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  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 
 Sent: Saturday, June 11, 2005 10:55 PM
 To: CF-Talk 
 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?
 
 
 
 



~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:209258
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe

RE: best way to invoke a cfc

2005-06-12 Thread James Holmes
If the host does disable cfobject, you can get the same effect by using
cfinvoke on a special method in the CFC that returns THIS. That way you
get the instantiated component once, rather than having one
instantiation for every cfinvoke call. 

-Original Message-
From: dave [mailto:[EMAIL PROTECTED] 
Sent: Monday, 13 June 2005 5:23 
To: CF-Talk
Subject: Re: best way to invoke a cfc

Thanks Jared,

 the reason I asked is I am back to working on a friends site that I
haven't messed with for awhile and I was creating the cfc objects in the
Application.cfm with cfobject name=getNewestListings
component=cfc.newListings.

 and I was thinking that if at some point the host disables cfobject
then I would be f*cked, it works well but maybe I should be changing
this one now.

~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:209262
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


best way to invoke a cfc

2005-06-11 Thread dave
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?

~Dave the disruptor~
A criminal is a person with predatory instincts who has not sufficient capital 
to form a corporation. 



~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:209232
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


RE: best way to invoke a cfc

2005-06-11 Thread James Holmes
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:209236
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=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: best way to invoke a cfc

2005-06-11 Thread dave
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 cf-talk@houseoffusion.com
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:209238
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=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54