Dynamically Adding Methods to a CFC
When ColdFusion 9 came out, I found that FileMgr.cfc would not work on it. For one function, I had directly copied the DirectoryList UDF by Ray Camden. This allowed me to use cfdirectory recursively in CFMX (the "recurse" attribute not being available natively until ColdFusion 7).
This worked great until ColdFusion 9 came out. ColdFusion 9 added a built in function named (you guessed it!), DirectoryList. As a result, the FileMgr.cfc threw an error whenever it was instantiated on the code attempting to create a DirectoryList method. The problem here is that I have a lot of external code using that method, so renaming it would be a bit difficult. I would have to track down and change code in several different sites on several different servers. Not only that, but as FileMgr.cfc is publicly available code, everyone using it would have to do the same. Needless to say, this isn't a desirable outcome.
Fortunately, ColdFusion makes it easy for me to maintain my API and still avoid the error telling me that I can't have a function named "DirectoryList". The surprising thing about this is how easy it is.
There are no comments for this entry.
[Add Comment]