Oh, ok, so CFINVOKE is overkill. Got it.

I do have the components created in application.cfc ie. <cfset
Application.dns = CreateObject("component", "admin.cfc.dns") />

So where I have

<cfinvoke component="admin.cfc.dns" method="dnsParseURL"
returnvariable="dnsParseURL" url="#cgi.server_name#"/>

What would I do in it's place? The idea is to pass an argument named
'url' to the method, and return a structure containing several
variables generated by stripping down the url. (domain, subfolder,
etc)

Should I set the variable name to what I set as returnvariable? Will
this new variable be the structure that the function produces?

<cfinvoke component="admin.cfc.dns" method="dnsParseURL"
returnvariable="dnsParseURL" url="#cgi.server_name#"/>
vs.
<cfset dnsParseURL = Application.myCFC.dnsLookup(cgi.server_name) />





On Fri, Jul 6, 2012 at 6:24 PM, Matthew Woodward <[email protected]> wrote:
> On Fri, Jul 6, 2012 at 4:18 PM, Jason King <[email protected]> wrote:
>>
>> Assuming the business logic is right, and everything works as I want
>> it to, does anybody see any red flags?
>
>
> CFINVOKE creates the component, calls the method, and then destroys the
> component. So while ultimately the compiler may be smart enough not to
> literally do this every time (I can't confirm that myself), strictly
> speaking in your code below you're creating an instance of that same
> component half a dozen times which is very inefficient. This is why I
> suggested that if this CFC has functions that are used over and over again
> you'd want to instantiate the component once when the application starts and
> call functions on the instantiated version.
>
> As I said in a previous email the only time I ever use CFINOVKE is when I
> need to call a function name that's a variable. Other than that, if you
> choose not to instantiate the component once on application start for
> whatever reason, you'd be better off (not to mention the code would be much
> more readable) if you instantiate the component once and then simply call
> methods on the instantiated component instead of calling CFINVOKE over and
> over.
>
> --
> Matthew Woodward
> [email protected]
> http://blog.mattwoodward.com
> identi.ca / Twitter: @mpwoodward
>
> Please do not send me proprietary file formats such as Word, PowerPoint,
> etc. as attachments.
> http://www.gnu.org/philosophy/no-word-attachments.html
>
> --
> online documentation: http://openbd.org/manual/
> http://groups.google.com/group/openbd?hl=en

-- 
online documentation: http://openbd.org/manual/
 http://groups.google.com/group/openbd?hl=en

Reply via email to