This is the big question, isn't it? It's not really an either/or kind of question.
Modules and custom tags are basically the same. You can run custom tags using CFMODULE or with <CF_> style format. It just depends on the type of syntax you prefer to use. However one difference is that CFMODULE will let you specify a relative path: <CFMODULE template="../../admin/mypage.cfm"> so its more versatile. If you want to reuse pieces of code that are not somewhere in the tags directory, you'll need to use CFMODULE or CFINCLUDE. Modules/custom tags have a definite advantage. They are encapsulated. Any variables declared in a custom tag (except global type variables such as Request, Session, Form, etc.) exist only in that custom tag. So it is harder to accidentally overwrite variables in the calling page within your custom tag (or vice versa.) You can pass variables to custom tags like so: <cf_mytag variable1="my value"> and within the custom tag read those values in thru the attributes scope like so: #attributes.variable#. This makes custom tags much like functions in Javascript, Java, Basic, etc. You can also pass values back to the calling page but you have to be careful because you CAN overwrite stuff in the calling page. You use the caller scope like this: <cfset caller.returnvalue = "my value"> and in the calling page you can read that variable like any other: #returnvalue#. CFINCLUDE is extremely different animal than CFMODULE or tags. I tend to only use CFINCLUDE when reusing bits of display/HTML code as its less safe programatically. However, there is more overhead with CFMODULE/Tags than CFINCLUDE because of their encapsulation. CFINCLUDE acts as if it its code was just pasted into the page and is not in its own seperate memory space at all. So in rare occasions, I use CFINCLUDE to resuse logic that is within a really long <CFLOOP> or otherwise has a lot of overhead. But I wouldn't rely on it as the main form of code reuse---your're asking for headaches in maintenance. Coldfusion MX brings in a whole new animal called CFC's which are great for code reuse as they add object-oriented style features to coldfusion. They are like custom tags on steroids (sort of) but are a little more complex. In my opinion, I would use CFC's for all my data/business logic and use CFMODULE/CFINCLUDE only for reusing display logic and HTML, unless there way some major perfornance hog in my code. If you are stuck in CF 4.5/5 like my workplace is, then I'd use CFMODULE/tags to reuse business/data logic and CFINCLUDE only for display reuse. A pretty good "best practices" article on CFMX and CFC's that I've seen is this one: http://www.benorama.com/coldfusion/index.htm Hope this helps. Does anyone disagree? Craig ----- Original Message ----- From: "Cutter - (CFTalk List)" <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Monday, November 11, 2002 11:11 AM Subject: Custom vs Module vs Include.... > Can I get some input here. > > We are using mostly CF 4.5, with one 5.0 server and several CFMX servers on > the way. For now though the question is, which is the best, most productive, > lowest load and overhead method to use for reusable application code? There > is some debate here as to the viability of using custom cf tags instead of > implementing them as modules (or, in some cases, as includes). > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.

