Mike... Care to share one small code example? How are you initializing this User bean? Do you just pass it an id? How are you storing the values inside the user bean? Do you really have individual UPDATE queries just to set each field value?
It sounds really awesome, but I'm not clear one some of those things. <!----------------//------ andy matthews web developer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --------------//---------> -----Original Message----- From: Mike Kear [mailto:[EMAIL PROTECTED] Sent: Monday, March 06, 2006 5:03 PM To: CF-Talk Subject: Re: OOP, why me? G'day Josh, I wanted to avoid using the OOP jargon terms that so confused me when I was learning, but a few sneaked in there. For all I know I have it confused myself, but it works for me so let me see if i can try and explain it without using the OOP jargon, then when you go and read a more knowledgeable explanation it might make more sense to you.... (note to experts - I know this is simplified, but that's what's sorely lacking to beginners at this OOP thing) A bean is a CFC containing a single object. Think of a query. It is an object that might contain a thousand records. We're all used to creating the query object at the top of a page, and passing it around the page, accessing the elements inside it at points down the page. A bean contains all the data relating to one record. A user bean for example might be a cfc that has a value for a single user's first name, last name, email address, username, password etc. So by passing the User bean to a page, in one element you pass everything the bean knows about one person. The only job the bean does is hold the data about one record so it can be passed around the site. Think of it as a coffee bean. In the coffee jar, there is a bean with "Kear" on it, and another with "Josh" on it and thousands of others. Want to know about "kear?" just get the "Kear" bean. (Actually what you do is initialise the User bean with the Kear data). Inside the "Kear" bean is a value "#user.getLastName()# and another value #user.getEmail()#. At any point, values can be changed it your app requires it by #user.setEmail()# Now the bean has a different value for email. The UsersDAO (Data Access Object) is the cfc that looks after all the database interaction with the Users table. It contains the CRUD (Create, Read, Update, Delete) methods and some others. It's where all your queries are. So to save the new email value to the database for example, you pass the User bean into the update() method of the UserDAO.cfc. ALL the values currently in the bean are saved to the User table. You dont need to check any more whether you have values for this field or that field, because ALL the fields always have values in the bean, even if they're Null values. This is not the only way to think of these things. But it's what I used in my CMS app, and it works pretty fine for me. Multiply this by 15-20 tables and before you know it you have a framework, whether you call it Model-Glue or MachII or Scaffolding. What the framework gives you is a defined, organised way or doing things so that others following along behind you or working along with you know what's going to be where. I'm doing some work right now on an old app that was written some years ago, and it takes me 40 minutes finding the code i want to change for every 5 minutes actually making changes. With a framework, that ratio is reversed. I hope this helps you. Cheers Mike Kear Windsor, NSW, Australia Certified Advanced ColdFusion Developer AFP Webworks http://afpwebworks.com ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month On 3/7/06, Josh Nathanson <[EMAIL PROTECTED]> wrote: > > Mike, can you please define two things in your message: > > 1. bean - I know this is related to the java style method of OO but can > you > please expound? > 2. DAO > > -- Josh > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234424 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54