• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

<cfinvoke component="12robots" method="isItEvil()">

LEGEND ,
Oct 26, 2012 Oct 26, 2012

Copy link to clipboard

Copied

In a recent discussion 12robots disparaged the cfinvoke tag with words such as:

"cfinvoke is an evil beast that serves a dark master. It is of occasional use, but in 99 out of 96 cases, it is ugly, ugly, and ugly"

While I rarely use it myself, I can think of one of those occasional uses.  Every once in awhile someone will post a question describing a situation where there hosting provider disallows the cfobject tag and createobject function.  That pretty much leave cfinvoke as the only alternative.

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 26, 2012 Oct 26, 2012

Copy link to clipboard

Copied

There, of course, is one other alternative. 

Jason

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 28, 2012 Oct 28, 2012

Copy link to clipboard

Copied

12Robots wrote:

There, of course, is one other alternative. 

Naturally. <cfcomponent extends="12Robots">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 28, 2012 Oct 28, 2012

Copy link to clipboard

Copied

Naturally. <cfcomponent extends="12Robots">

You'd still have to invoke the component somehow.

I presumed he meant the new operator.

And, indeed, if it's a persistent component, then there's entityNew() too.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 29, 2012 Oct 29, 2012

Copy link to clipboard

Copied

Actually, the other alternative I was refering to was to get a decent hosting provider.

jason

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 29, 2012 Oct 29, 2012

Copy link to clipboard

Copied

LATEST

Oh you and your lateral thinking...

😉

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 28, 2012 Oct 28, 2012

Copy link to clipboard

Copied

Regarding, "There, of course, is one other alternative."

Who invoked the anchor tag?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 29, 2012 Oct 29, 2012

Copy link to clipboard

Copied

What about using cfinvoke for queries?  All of the projects I've worked on for the current client, I'd say probably 95% of the component/methods I've seen or typed are just for queries.

^_^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 29, 2012 Oct 29, 2012

Copy link to clipboard

Copied

The fact that the method returns a query is not relevent.  For me, what would be more relevent is the number of functions in the cfc that are going to be called.  If it's one, then cfinvoke is fine.  If it's more than one, cfinvoke is inefficient because it creates a new object every time.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 29, 2012 Oct 29, 2012

Copy link to clipboard

Copied

(shrug)  Some components have 2-3 functions, some components have 10 or so functions.  Some of the queries are quite large, most of them are just a few lines.

^_^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 29, 2012 Oct 29, 2012

Copy link to clipboard

Copied

You're talking about the return value, not what the <cfinvoke> actually does.

And why would you use:

<cfinvoke component="SomeComponent" method="someMethod" returnvariables="someVariable">

When you could just do this:

<cfset someVariable = new SomeComponent().someMethod()>

<cfinvoke> is just a sh!tty, ugly, always unnecessary syntax construct. It's a reminent from when the thinking in CFML was "it's a tag-based language, everything must be done via tags", which was always an illconceived approach to implementing the language.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 29, 2012 Oct 29, 2012

Copy link to clipboard

Copied

For the project I'm currently working on, I just switched all the cfinvokes over to variable = new components.componentName().methodName(args) and must admit that reducing code from 10 lines to 3 is pretty nice and easy to read.

I'm sure I'll expand into different things as time goes on.

Thanks, guys.

^_^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 29, 2012 Oct 29, 2012

Copy link to clipboard

Copied

Regarding

"

And why would you use:

<cfinvoke component="SomeComponent" method="someMethod" returnvariables="someVariable">

When you could just do this:

<cfset someVariable = new SomeComponent().someMethod()>"

In Dreamweaver, which I use, the former would kick in the autocomplete feature, the latter would not. 

Plus, the latter syntax is new to me.  I'm used to creating the object first and then calling the variable.  I haven't tried it, but I'm not even sure the latter syntax would work.  I might try it later.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation