Best means of setting a library of reusable code

2013-06-25 Thread Rick Faircloth
Hi, all... I've been writing code for every project I've worked on for the last 10+ years. I did that purposefully to make myself work in a manner which would, hopefully, not cause me to rely on known practices because they were familiar and understood, but always strive to discover better ways

Re: Best means of setting a library of reusable code

2013-06-25 Thread Russ Michaels
if you use EXTENDS, then everything in the parent CFC is available tot he child. If you want libraries to use on multiple sites, then you would need to put the components in a central location and then adding a mapping to them. On Tue, Jun 25, 2013 at 4:01 PM, Rick Faircloth

Re: Best means of setting a library of reusable code

2013-06-25 Thread Rick Faircloth
Alright, that's the confirmation I needed to proceed. So, use 'extends it is! Thanks, Rick On Tue, Jun 25, 2013 at 11:21 AM, Russ Michaels r...@michaels.me.uk wrote: if you use EXTENDS, then everything in the parent CFC is available tot he child. If you want libraries to use on multiple

Re: Best means of setting a library of reusable code

2013-06-25 Thread Matt Quackenbush
Hang on a minute. If I understand this correctly So, how do I make the variables from application.cfc available to contact.cfc under such a scenario? Does the extends functionality of cfc's solve this? ... you're thinking about adding `extends=Application` to your contact.cfc? If

Re: Best means of setting a library of reusable code

2013-06-25 Thread Brian Cain
I have to agree with Matt. You are setting yourself up for a dependency nightmare if your cfc functions do not encapsulate their logic. On Tue, Jun 25, 2013 at 10:50 AM, Matt Quackenbush quackfu...@gmail.comwrote: Hang on a minute. If I understand this correctly So, how do I make the

Re: Best means of setting a library of reusable code

2013-06-25 Thread Russ Michaels
taking best practices into consideration is a whole different matter, but his original post implied he just wants to keep his existing code. Having global functions in your application.cfc is pretty common evrn if not a best practice. Russ Michaels www.michaels.me.uk On 25 Jun 2013 16:54, Brian

Re: Best means of setting a library of reusable code

2013-06-25 Thread Dave Watts
However, the contact.cfc has to reference variables setup in the application.cfc, which exists inside the website root. Unless I place the application.cfc in the same folder as contact.cfc, it doesn't work. So, how do I make the variables from application.cfc available to contact.cfc under

Re: Best means of setting a library of reusable code

2013-06-25 Thread Matt Quackenbush
On Tue, Jun 25, 2013 at 12:04 PM, Dave Watts dwa...@figleaf.com wrote: In general, you don't want to use Application.cfc as the parent class for any other class except another Application.cfc - for example, in a subdirectory of the parent application. You don't want to use it as the parent

Re: Best means of setting a library of reusable code

2013-06-25 Thread Rick Faircloth
Your understanding is correct, Matt, but I don't see how your example is relevant. In my application.cfc, I've got a line that sets an application variable: cfset application.siteShortDomain = myShortDomain.com I need that application.siteShortdomain variable available when contact.cfc runs.

Re: Best means of setting a library of reusable code

2013-06-25 Thread Rick Faircloth
Dave: Is contact.cfc part of the same application as the Application.cfc where the variables are defined? No, I'm trying to figure out a way to have a common library of cfc's, js, etc., that websites I build can reference. I saw in other places around the Internet that it's best to keep code

Re: Best means of setting a library of reusable code

2013-06-25 Thread Matt Quackenbush
You do it exactly like I said you do it: Pass it in as either an argument or a property. When you instantiate your contact.cfc, you pass in everything it needs from outside in order to do its job. The example I gave is completely relevant, albeit not an example of your exact situation. I don't

Re: Best means of setting a library of reusable code

2013-06-25 Thread Dave Watts
In my application.cfc, I've got a line that sets an application variable: cfset application.siteShortDomain = myShortDomain.com I need that application.siteShortdomain variable available when contact.cfc runs. So, how would I go about this? From within any file that's part of that

Re: Best means of setting a library of reusable code

2013-06-25 Thread Azadi Saryev
With AJAX-accessed cfc's you really need them under your web root. CF mappings won't work with those. Creating a virtual dir in your web server pointing to the cfc location will do the trick. On Wed, Jun 26, 2013 at 1:58 AM, Dave Watts dwa...@figleaf.com wrote: In my application.cfc, I've

Re: Best means of setting a library of reusable code

2013-06-25 Thread Rick Faircloth
From within any file that's part of that application, you can directly reference application.siteShortDomain: cfoutput#application.siteShortDomain#/cfoutput Any file within the same directory, or any subdirectories that don't have their own Application.cfc or Application.cfm files, are

Re: Best means of setting a library of reusable code

2013-06-25 Thread Rick Faircloth
Matt, just participate in the conversation without being asinine about it. I haven't asked anyone to write my code for me. Just looking for some guidance as to the correct approach. So, offer your advice in a friendly manner, if you're going to offer it at all. On Tue, Jun 25, 2013 at 12:56

Re: Best means of setting a library of reusable code

2013-06-25 Thread Rick Faircloth
Thanks, Azadi... I was afraid that or creating CF Admin mappings might end up being the answer. I was trying to find a way of accessing the variables without a lot of setup for each website. But, virtual directories won't be that much to do, since the virtual directories will be the same for

Re: Best means of setting a library of reusable code

2013-06-25 Thread Matt Quackenbush
sigh I did. And you flatly stated that my example is (not) relevant. I was merely pointing out - mostly for those who happen upon this thread later, since they'll hopefully read and comprehend - that your assessment is flatly wrong. Good luck. On Tue, Jun 25, 2013 at 2:24 PM, Rick Faircloth

Re: Best means of setting a library of reusable code

2013-06-25 Thread Rick Faircloth
Well, the good news is that I can include the application variables in the AJAX post and pass them into the contact.cfc (which is also out of the webroot and in the library) via the AJAX call to contact.cfc. The bad news is, I have to type all those application variables into every AJAX call.

Re: Best means of setting a library of reusable code

2013-06-25 Thread Rick Faircloth
sigh No, Matt... I didn't say your example is (not) relevant. I stated, I don't see how your example is relevant. See the difference? I put the fault on my part for not understanding your example. Your example may be perfectly relevant, but I couldn't see how. I think you just misread my

Re: Best means of setting a library of reusable code

2013-06-25 Thread Matt Quackenbush
Fair 'nuff. :-) On Tue, Jun 25, 2013 at 3:11 PM, Rick Faircloth r...@whitestonemedia.comwrote: sigh No, Matt... I didn't say your example is (not) relevant. I stated, I don't see how your example is relevant. See the difference? I put the fault on my part for not understanding your

Re: Best means of setting a library of reusable code

2013-06-25 Thread Carl Von Stetten
Rick, I don't know if this will help, but I've read about people creating proxy CFCs in or below the webroot specifically for AJAX requests. Those proxy CFCs either extend the protected CFCs (the ones outside the webroot) or have functions that call the protected CFCs through createObject()

Re: Best means of setting a library of reusable code

2013-06-25 Thread Rick Faircloth
Thanks for that info, Carl... I think I read somewhere about that while researching. I'll take another look and see if I can make that work. It'll beat typing in all the application variables for every call to the cfc's! Rick On Tue, Jun 25, 2013 at 3:39 PM, Carl Von Stetten