> -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf > Of Barney Boisvert > Sent: Friday, May 07, 2004 5:11 PM > To: [EMAIL PROTECTED] > Subject: RE: [CFCDev] CFINCLUDE forces var scope into arguments? > > The real question is why you'd ever use CFINCLUDE inside a CFC. I've > though > about going that route, but the only reason is to get around the > shortcomings of the tools available. If you need to reuse a block of code > inside a CFC, use a function, don't use an include. Problem solved. >
The only reason I had been using it was to abstract methods to be used with multiple data types. For example a "Thing" component might have a "Save()" method would (based on a system setting) automatically call one include for SQL Server, one for Access, one for XML, etc. Each of these includes would return the same thing to the method. The method would handle communal validation, error handling, etc. There was a separate include for each method and for each persistence type. In this way the same system could use any number of DBs and be extended to new ones very simply. In other words this wasn't to reuse a block of code, but to create effectively dynamic code blocks while maintaining CF's built-in type validation. With this issue on the table however I'm playing now with replacing my includes with sub-components. My current thoughts are to generate a "Broker" component for each persistence type... my "Thing" component would have a "Thing_Broker_MSSQL2000.cfc" component which would have just the MS SQL 2000 specific code and a "Thing_Broker_MSAccess.cfc" for Access and so forth. The problem with this has always been CF's inability to use dynamic values in arguments (you can't easily type validate a non-specific component). I think it can be done, but it won't be as elegant, I think, as CFINCLUDing just that DB-specific code. Jim Davis ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
