So I had my big winge about CFCs being able to create other CFCs relatively, but not being able to extend or use return or cfargument types relatively, and how it totally messes up code being truly reusable.
So I’m chatting to Spike about this issue, and he’s looking at my post, and he casually remarks to me: ‘Well, why don’t you try ” rather than ‘.’? See what happens".
I of course thought to myself, no way is that going to work.. I mean, it’s just silly. It doesn’t even look like a real class name definition.
Well I’ll be damned (and several other loud expletives I echoed at the time), it freakin’ works. And to top it off, it works relatively. Spike came up with the good once again.
So to make myself clear through all this muddle – you are perfectly able to:
– i.e. create Dog.cfc in the folder comlevel folder relative to where you are calling it.
<cfargument name="Cat" type="comlevelCat" required="true">– i.e The type of the argument is of the Cat.cfc up in the comlevel folder relative to the CFC this is in.
<cffunction name="getDog" access="private" returntype="comDog" output="false">– i.e The return type of the function is of the Dog.cfc up in the com folder relative to the CFC this is in.
<cfcomponent name="Dog" extends="levelextendExtend">
– i.e. extend the component Extend.cfc in the relative directory of levelextend to the CFC this is in.
This is really big thing as it means that you can relatively go down a folder tree with your inheritence and typing with CFCs. You can’t actually go back up (least I haven’t found a way), but you can go down it. This means, you have much more ability to write really portable code – as long as you are relatively careful (no pun intended) about how you structure your packages.
for example – if I have a directory structure of:
i can now make a extend b without going back to root and/or a mapping via:
<cfcomponent name="a" extends="oneb">
As well as do similar things with
return values on
Here you can download my relative pathing testbed so you can test it out for yourself, and see all the possibilities.
Quite frankly, this has opened up a whole lot of interesting things in terms of how I want to structure my code, and whether or not a cfmapping is even required when doing CFC development.
No cfmapping – how cool is that?