On Nov 16, 2007 8:08 PM, Dominic Watson <[EMAIL PROTECTED]>
wrote:
> >
> > What you've described is not the same as what the original poster is
> > asking
> > about. He want to use relative paths.
>
>
> What I described is exactly as the link that you posted in your original
> response and is a solution to the OP (though clearly not the best). He
> wants
> to be able to use a cfc that lies in a directory a back from the calling
> template. This allows you to do that, as does a mapping.
>
No, it isn't. Your function requires the caller to pass in the proper path
to the getCFC() function. The link to Ben's blog does not, it automatically
builds up the proper path based on assumptions about the base path. Did you
look at his post? Clearly you must see that this part of his code is
significantly different from yours?
<cfreturn CreateObject("component", ("www_cfc." & ARGUMENTS.Path)) />
You need to know the same amount of information about the location of the
> cfc as you would using a standard mapping. Placing and using the udf in a
> directory called c:\wwwroot\myfolder\ has the same effect as using a
> mapping
> to that same folder. Components can be organised into subdirectories and
> it
> will work the same.
I'm not sure what you're saying here, but I hope you aren't trying to assert
that it's better to have hardcoded path references to create components all
over your code instead of using a mapping? If so, you're incorrect, because
with a mapping you are free to use any physical path you want. You can move
servers or change directory structures all you want, as long as you have a
valid mapping set everything will still work. With your approach you have to
specify the proper physical path every time you call getCFC(). Using a
mapping is vastly more flexible. It's simple to do in any version of CF, and
with CF8 and application-specific mappings there's just no reason not to use
them.
>
> > Also, just to be clear on the names, what you have here (getCFC()) is a
> > function, not a method. A function is standalone, while a method is
> > invoked
> > on an object.
>
>
> Quite right to make the distinction, and my bad; though I should say that
> a
> method belongs to or is part of an object rather than anything 'on' to
> one.
>
> The solution is certainly small scale and it's benefit is in portability
> and
> independant deployment with a small project for which it is not desirable
> to
> have the end users (developers) have to set up a mapping each time they
> wish
> to use it (if you can unzip something into a folder and have it working
> straight away I say hoorah)!
>
Again, to be clear, no one is forcing you (or anyone) to use a mapping. You
can unzip the folder into a specified directory and it can work fine without
a mapping. It just has to be the right directory.
>
> It is also not desirable for use in calling components from within other
> components (I missed this in the OP, just read the title and your reply)
> although I'd say appliation.cfc MIGHT be an exception to this.
>
> Anyways, apologies for all the inflammatory tones
>
I don't think anything has gotten to the point where you need to apologize,
but I do think that you are going to reach the point (sooner rather than
later) where following this kind of simple factory approach is going to come
back and bite you. If or when that happens, come on back and I'll be happy
to try and help get you up to speed with a dependency injection framework.
As is often the case (and this was true with myself and with Sean Corfield,
among others), until you feel the pain that ColdSpring is addressing, it
seems like overkill or extra work. Afterwards, you'll wonder how you ever
did development without it.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Check out the new features and enhancements in the
latest product release - download the "What's New PDF" now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:293531
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4