Skip to main content
Inspiring
December 23, 2009
Question

Best practices for common code

  • December 23, 2009
  • 3 replies
  • 718 views

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

    This topic has been closed for replies.

    3 replies

    BKBK
    Community Expert
    Community Expert
    December 29, 2009
    What is the best practice?

    Of all? Read up on the subject.

    Google Coldfusion components

    Adobe documentation on Coldfusion Components

    BKBK
    Community Expert
    Community Expert
    December 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.

    Inspiring
    December 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

    Inspiring
    December 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....

    ilssac
    Inspiring
    December 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.