Okay – a bit of a rant… and this has probably been shown before, but this definatley threw me when I saw it..
1st off. I hate having to use a CF mapping when using CFCs. Totally defeats the purpose of portable/reusable code in my mind.
I've been playing alot with trying to keep my code non-mapping required. It's been taking it's toll, but I'm sorta-kinda getting there.
So with that in mind, I started a recent project with all my CFCs in one directory, so they could see each other, with the idea of refactoring into packages last, once I was happy with how it was working.
So I start refactoring, and I run into this fantastic doozie.
— dog.cfc —
— Test.cfc —
<cffunction name="init" hint="Constructor" access="public" returntype="Test" output="false">
var dog = createObject("component", "com.Dog");
<cffunction name="setdog" access="public" returntype="void" output="false">
<cfargument name="dog" type="com.dog" required="true">
<cfset instance.dog = arguments.dog />
— index.cfm —
So, basically, what happens is: You create a new 'Test', it creats a new 'com.Dog', and then when you go to set it via the setDog(), it tells you:
The argument DOG passed to function setdog() is not of type com.dog.
WTF? Your telling me, that you can work out in relation to the Test.cfc enough information to create a 'com.Dog', but you can't work out the same thing for typing on a cfargument???? Why bother giving us the one, if you can't give us the other?
I just wish that Coldfusion had a way that was either designated, or programtically determ a single root directory for all your CFCs to reside. Much like a J2EE app has /WEB-INF/classes for .class files to reside. That way you COULD have packages much like you can in Java, and not have to worry about portability issues with cfmappings.
(I also wish for the ability to jar up a series of CFCs and import them as a library, again like J2EE… but I think that is asking too much)
As it stands, I think I will experiment with having all my CFCs in one directory, and see what issues arise. It's not an ideal soultion by a long stretch, but it allows me to develop without mappings for now.
— end rant