views:

74

answers:

2

Does ColdFusion offer a mechanism for splitting CFCs into multiple files? I am NOT talking about extension, I am talking about splitting the SAME CFC into multiple files; the same way C# allows for "partial" classes. The reason for this is because I am using T4 to generate a bunch of CFCs and I want to be able to tag functionality onto the generated CFC by doing so in another file. I want to do this in a way that doesn't violate the Open-Closed Principle.

+1  A: 

No, sorry. A limitation of the language, I'm afraid. A CFC is a single file.

I mean, of course, you could bastardize it somehow. You could have fragments that are wrapped in a cfcomponent tag as part of some kind of build process, but I'm pretty sure that's not what you're looking for here.

Shawn Grigson
+3  A: 

<cfinclude> will work as far as basic functionality is concerned, however the following will not work correctly:

  • Metadata functions - only the functions within the inspect CFC will be shown - not the cfincluded functions
  • <cfajaxproxy cfc="your.cfc"> will not allow the included methods to be called through javascript
  • Calling included functions as a web service call will not be possible

(all these cases basically boild down to the metadata only seeing the functions etc. which are within the base cfc)

It might be worth you googling Coldfusion Mixins for more detail on this and other related techniques.

Danlance