« Ben Forta Holds Forth on ASP.NET and ColdFusion | Main | OT - What's your Handheld of Choice? »

October 09, 2003

Where Do You Put Your Components?

The Macromedia Web Technology Group, in their most recent ColdFusion MX Coding Guidelines, recommends that you put components which are to be accessed directly either through Flash Remoting or web services in {cfmxroot}/wwwroot/{applicationname}/ and any other components should be stored under {cfmxroot}/extensions/components/{applicationname}/. I sometimes do something similar, although I generally use {cfmxroot}/com/macromedia/apps/{applicationname}/ instead. This works well for applications that you write, install and configure yourself, however I found that when I wanted to distribute an application, I preferred having all the application's files in a single directory. Therefore, I have started putting all application-specific components -- whether or not they are accessed directly through the browser, Flash Remoting or web services -- in {cfmxroot}/wwwroot/{applicationname}/components/{subdirectory}. At first, this may not appear to be the most elegant relationship, however I like the idea of having people unzip a single directory in their web root, set up a data source, tweak a few configuration parameters in the Application.cfm file or an external XML file, and be up and running. Now there's really no reason you can't do the same thing with your components outside your application directory, however I have found both packaging and unpacking to be more straightforward when everything is contained in a single directory.

So my current thinking is that I try to consider the type of application that I am writing and what it is intended for before deciding where to place my components. Where do you put yours?

Also, one circumstance that the WTG coding guidelines does not address is the location of generic, reusable components. For instance, I have a calc.cfc which performs certain mathematical functions in {cfmxroot}/wwwroot/com/macromedia/util, which has worked out well.

Posted by cantrell at October 9, 2003 04:02 PM | References

Comments

When we built FarCry CMS we wanted a component library that wasn't exposed under the webroot. We map that library with an application variable so it can really sit anywhere. But we chose to stick CFC packages into a directory called ../applicationroot/packages/*.*.

Were we wrong? Should we have used ../applicationroot/au/com/daemon/farcry/*.*? Generally I don't think so because the FarCry framework reserves the packages location for FarCry CFCs -- there is no fear of competing in the namespace.

Incidentally for standard components, for instance the ones I borrowed from Pollster we do the same as you've indicated.

PS. FarCry v2 just released (http://farcry.daemon.com.au/) -- largest CF open source code base in the world :)

Posted by: Geoff Bowers at October 9, 2003 06:37 PM

Personally - I normally build a 'web-inf' folder under the root of my application.

In there I have stored my XML config files (web.xml etc), and then have

web-inf/components
web-inf/udfs
web-inf/customtags

Usually each of those 3 directories is given a mapping, which is specified in my XML configs.

Personally, I feel that components should be application specific. If you have a component that you use on multiple applications, pick it up and move it.

If that said component is changed, I would prefer to test it individually on each application before moving it straight to production anyway.

But - toss up either way, and also dependent on if you are on a hosted / dedicated server, and what control you have.

JMHO.

Posted by: mark at October 9, 2003 10:23 PM

Currently, I keep all my components outside the webroot. This works well for me because I have no need to package and deploy, other than moving from the devlopment to production environment.

If the circumstances were different, I may place my components under the webroot to ease the package and deploy process.

Posted by: Andy at October 10, 2003 05:32 AM

I prefer the route of keeping components with the application, be that in either the application folder structure (i.e in Jrun4, {jrun_root}/servers/{server}/cfusion-ear/cfusion-war/WEB-INF).

or in the web root ( {web_root}/{application}/cfc/...)

trying to follow along with the Java application architecture, you'd want to keep things together to avoid confusion and the need for multiple mappings.

JMHO

Posted by: Matt at October 10, 2003 04:26 PM

Thank you for the wonderful website and information I will be back soon, nice Site

Posted by: Martha at December 22, 2003 09:11 AM

Congratulations to your fantastic Site. Thanks

Posted by: Abel at December 22, 2003 09:12 AM

levitra

Posted by: kalina bender at December 22, 2003 05:45 PM

levitra

Posted by: levitra at December 22, 2003 05:46 PM

Best firm Micromedia this in POLSCE which possesses flasha !
I greet !

Posted by: SMS - Logo - Dzwonki at December 24, 2003 09:29 PM

To admit fly that it is this very interesting thing !
I greet polaków in name of everybody!

Posted by: Domeny - Hosting at December 24, 2003 09:32 PM

Sie pleases me very this, damage from so it writes thinly English ; in English because for sure my express former to longer !

Posted by: Webmaster Serwis PHP and HTML at December 24, 2003 09:35 PM

Congratulations to your fantastic Site. Thanks

Posted by: Locual at December 25, 2003 08:56 AM

What ?

Currently, I keep all my components outside the webroot. This works well for me because I have no need to package and deploy, other than moving from the devlopment to production environment.

If the circumstances were different, I may place my components under the webroot to ease the package and deploy process.

Is thys ?

Posted by: Dzwonki polifoniczne at December 25, 2003 02:55 PM

Pozdro pezet !

Posted by: DIVX at December 26, 2003 08:28 AM

Congratulations to your fantastic Site. Thanks

Posted by: Rubén at December 29, 2003 11:35 AM

Outstanding web.!

Posted by: Peter at January 3, 2004 10:23 AM

bingo

Posted by: bingo at January 4, 2004 12:00 AM

Congratulations to your fantastic Site. Thanks

Posted by: sms bramka sms dzwonki logo nokia at February 24, 2004 12:55 AM

cool site:)

Posted by: sms bramka sms dzwonki logo nokia at February 24, 2004 12:58 AM

I've never though about that before!

Posted by: NStarer at February 24, 2004 01:45 PM

Wow, very sweet nlog

Posted by: propecia at March 9, 2004 09:41 PM

Wow, very sweet nlog

Posted by: propecia at March 9, 2004 09:47 PM

Druckerpatronen

Posted by: Druckerpatronen at May 11, 2004 03:16 PM

Druckerpatronen

Posted by: Druckerpatronen at May 11, 2004 03:26 PM