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 ----- Original Message ----- From: "Mike Kear" <[EMAIL PROTECTED]> To: "CF-Talk" <[email protected]> Sent: Monday, March 06, 2006 2:11 PM Subject: Re: OOP, why me? > This thread has drifted away from Gareth's original question. There's > nothing wrong with that, but I dont think anyone's actually answered > him. I'm going to have a go at it . > > Why bother with OOP, when other ways get the job done? > > I'm a recent convert to OOP. I struggled with it for ages, till finally > the > light came on and i had one of those "Eureka!" moments when it finally > made > sense. And I'm extremely grateful that it did. Gareth, I strongly urge > you > to keep on with it and you'll see the light, I feel sure. Let me tell > you > some of the things I find helpful about this process. I'm sure you've > seen > the arguments from the likes of Hal Helms et al. and thought as I did > "that > looks really great, but I can't see where I get practical benefits out of > all that work to learn it." > > Perhaps I can give you a parallel .... when you learn how to style pages > with CSS, suddenly the separation of style and look and feel from the code > is very liberating. Your code is simpler and easier to maintain. Using > OOP gives you similar benefits. > > When you do a query on a database, you then move that query object around, > getting access to the elements in that query, which might number thousands > of elements with a few logical, easily understood CF expressions. Well > when you use OOP techniques, you get that same benefit in many other > ways. Instead of just queries you're bouncing around your pages, you can > manipulate other neat little bundles of data. > > For example, I usually use beans. Say for example a User bean. There's > a > value in the bean for every field in the User table. So if I'm doing a > user profile form for example, I'll know that once the bean is created > there > will always be a value for every field in the form. Gone forever is the > "variableA is not defined" errors that drove me crazy before. When I > create > a User bean, and initialise it with the Kear record, I know that when I > pass > the bean to a page, every detail about Kear is available with for example > #User.getFirstName()#. > > During January, when everyone else was having a holiday relaxing on the > beach, I was sitting in the tent writing my new Content Management > System. It's the most complex app I've ever written. But it was a joy to > write. Because I decided long ago that no matter what it took, I was > going > to persevere until I understood this OOP thingy, I only used this bean/DAO > approach to it. And the end result includes the following: > > - It's easy to build because OOP forces you to modularise all the > app's procedures into small, self-contained elements > - It's easy to maintain because of the above, and because you can find > the bit of code you want far easier. e.g. ALL your queries on the > User table will be in the component UserDAO.cfc (in my example) > - The resulting app is far more robust than any app I've ever > written. To my astonishment I found I was regularly writing bits of the > application that worked first time, no errors. And far fewer bugs to > iron > out that I'd been used to. > - The CMS is more complex than anything I've ever done, but works > faster and is easire to customise than anything I've ever done. Since I > built it, I've added major elements, and made numerous minor changes as > I've > had client reaction, and it's a breeze to do. > - The CMS is easily deployable. Since I built that one in January, > I've reproduced it and customised it for 4 more sites that are about to > be > deployed. I wouldnt have DREAMED of attempting to build 5 sites > simultaneously before. The sites look totally different ot the casual > visitors, but they are built on the same core code, with all the > differences > being in a few places in teh code, put there to hold customised > elements, > and with different CSS style sheets. > - This OOP thing has allowed me to get my mind organised to the point > where I have a code generator to look after most of the drudgery of > writing > all those getters and setters and common methods. > > In short - it's bloody magic! > > Gareth, until you have that "eureka moment" it looks like a lot of effort > to > learn all this strange language for little return. I'm far from an > expert, > but I've been through that 'Eureka moment" and I can see that persevering > is worth it. The terminology is confusing at first, and some people seem > to > like dumping a whole lot of strange jargon on you which bamboozles the > beginner (which is in part why I've tried to keep away from it entirely > here) but focus on what it does for you. In my case, i reasoned that if > all those programmers talked and lived this OOP thing so much, and wrote > such complicated programs of all kinds with it, there must be something I > could learn from it. > > I think you can too if you keep on going with it. If i can help you > ( or > anyone else for that matter ) off line, please contact me. > > 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 > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234312 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

