Rick, imagine how it would be if (as is fairly common) you have business objects (beans) handling single items, and DAO cfcs handling all the database interaction back and forth. This is the scenario i drew in the tutorials I wrote ...
So in the application scope you have a DAO - just one . sitting in RAM waiting to be called on. And as people come and go through the site they're causing beans to be created all over hte place to manipulate the things they're needing as they move around. If (as happens frequently in one of my sites) there are 400 concurrent users, and only one DAO for this applicatoin, imagine how many people are likely to be simultaneously using an "Add()" method in the DAO. In those circumstances it's absolutly essential that the methods in teh DAO to e threadsafe. That means ALL variables inside the methods have to be var'd unless there is a specific reason not to. It means you have to build teh DAO carefully so data from one user doesn't interfere with the data from the others. But that's also true if you only have 3 simultaneous users. You still dont want their information - maybe their shopping carts getting intermingled. But on the other hand if you dont have the DAO sitting in the application scope, every time anyone uses that part of the application, the DAO has to be instantiated again. There's an overhead processing price to pay for doing that. Here's my rule of thumb. Vary away from it only once you realise the implications ... never require a cfc to know anything about the outside world. Anything it needs to know, you'll tell it. So that means you tell it what the dsn is. you dont ask it to go look in the application vars for it. You tell ilt what the different values are for the arguments, either by passing in a struct such as form struct or by passing in the values individually or by passing in a bean. But the cfc doesnt have to go looking for it, and doesnt have to know where it came from This is exactly how most of the built-in functions in coldfusion work. The function replace() doesnt have to know anything - you give it the information it needs to do its job. the replace() function doesnt do much - it does a limited job quickly and efficiently but its a small job. that's how to design your methods in you own cfcs - small limited functions that dont know anything about the outside world apart from what you tell it, and they should be threadsafe so you dont have to use up all your ram and processing power with bazillions of copies of the same code running at once. Hope this helps I rather have the feeling that at the moment you're thinking the stuff i put in my tutorial is a lot of additional typing - it's all too hard and too much work. That's not a problem - it was for me too until suddenly the light went on and i had a few of those "EUREKA!!" moments. I can disctinctly remember the day i finally 'got it' about encapsulation. I was so excited i made the mistake of talking about it in an agitated manner to my wife to promptly told me to stop being so bloody stupid and put the garbage out cos it's garbage night. <g> Cheers Mike Kear Windsor, NSW, Australia Adobe Certified Advanced ColdFusion Developer AFP Webworks http://afpwebworks.com ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month On Thu, Oct 23, 2008 at 3:39 AM, Rick Faircloth <[EMAIL PROTECTED]> wrote: > I think I'm beginning to understand your reasoning. > It's just taking some time for me to get to the "best practices" of CFC > usage. > Trying to get "anything" to work at first keeps my projects moving, while > beginning to employ different coding techniques. I'm basically trying to > learn by writing code for projects that are going live with these updates > as soon as I can get them working...too busy for much practice. > > Also, I'm a solo developer and never plan to code while working for anyone > else..so as far as sharing code or compensation, it doesn't matter. My > client's > don't care, as long as the correct data shows up on their pages. > > But I am trying to figure out the best way to do all of this. > > Thanks, > > Rick > > Dawson, Michael wrote: >> Technically, they both will work. >> >> However, what if you have a different process of calling the same >> function that doesn't use the form scope? >> >> What if you want to call the same method as a web service? >> >> Your current system will fail at that time. >> >> <realitycheck> >> Of course, if you fully control your code and no one else will ever use >> it, then do what you think works best for you. >> >> I have some code that might not pass the approval of several people, but >> it works for me and I can understand it. >> >> If your code is not being compared to others, nor are you being judged >> as part of your compensation, it really doesn't matter. >> >> However, at some point, you will find that following these accepted >> principals will become beneficial. That is when it "clicks" and you see >> the light. >> </realitycheck> >> >> >> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314256 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4