RE: best way to invoke a cfc
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 . 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
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 . 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 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 lead
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: 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 <[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 > 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
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 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
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: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