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

Best practices for common code

Participant ,
Dec 23, 2009 Dec 23, 2009

We're currently having a 'discussion' in the office about components.

Some people here swear up and down not to use cf components on high volume sites due to the initiation overhead. Instead they think that using CFHTTP is the way to go.

Others say that cf components are fine to use on high volume sites, if written correctly.

What is the best practice?

Thanks

631
Translate
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 ,
Dec 23, 2009 Dec 23, 2009

The issue is a bit of a non-sequitur to me.  It's like saying "which is better: a car or a washing machine?" They're both machines,  but they do completely different things.

A component is an implementation of the OO concept of objects.  CFHTTP is for making HTTP requests.  Two different things.

If it's even possible to make a sensible performance comparison, CFHTTP is almost certainly going to be slower because it needs to make an HTTP request which has a bunch of network overhead, whereas instantiating a CFC is all done in memory (with an initial file system hit if it's the first time the CFC is used).

CFCs are not as performant as simple <cfinclude> calls, or probably even <cfmodule> calls / custom tag calls, which would be more sensible performance comparisons to make.  However the performance consideration is trivial compared to more likely performance considerations like poorly written code, DB and other external system calls... and... err... stuff like <cfhttp> calls...

The application architecture benefits of using CFCs greatly outweigh any performance considerations they might have.

--

Adam

Translate
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
Participant ,
Dec 28, 2009 Dec 28, 2009

Theoretically speaking, if following strict OO concepts causes your server to crash on a regular basis, then those concepts should not be followed in the language you are using for that application. However, I have never had this issue with CF, so that is a mute point. I also agree with you in everything else you say.

If the common code resides on seperate machines, can CFCs be used across the network?

Thanks....

Translate
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
Valorous Hero ,
Dec 28, 2009 Dec 28, 2009

SpiderFromMars wrote:

If the common code resides on seperate machines, can CFCs be used across the network?

Thanks....

As long as the machine calling the CFC can access that network locations in some manner.  This will involve changing the user permissions that ColdFusion runs under from the default "LocalSystem" that does not have network permissions, at least on Windows versions of ColdFusion.

Translate
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 ,
Dec 28, 2009 Dec 28, 2009

Regarding:

If the common code resides on seperate machines, can CFCs be used across the network?

In addition to Ian's answer, you can always call them as webservices.

Translate
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 ,
Dec 29, 2009 Dec 29, 2009
Theoretically speaking, if following strict OO concepts causes your server to crash on a regular basis, then those concepts should not be followed in the language you are using for that application.

Theoretically speaking, following strict OO concepts prevents your server from crashing on a regular basis.

Translate
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 ,
Dec 29, 2009 Dec 29, 2009

Others say that cf components are fine to use on high volume sites, if written correctly.

What is the best practice?

The best practice is to write CFCs correctly and to use them, wherever possible, on every Coldfusion web site. Why every? It is best practice to use the commonest CFC of all, Application.cfc.

Translate
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 ,
Dec 29, 2009 Dec 29, 2009
LATEST
What is the best practice?

Of all? Read up on the subject.

Google Coldfusion components

Adobe documentation on Coldfusion Components

Translate
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