Cliff Meyers wrote:
Beans (aka value object) and Transfer Objects (TOs) are all types of transfer objects. I've coined the term Lightweight Transfer Objects (LTOs) lately because not the a traditional TOs object as defined in the java docs, but almost sort of like an encapsulated transfer structure.Just curious here... I thought a bean was a kind of transfer object. Could you explain the difference between the "traditional" Mach-II bean and the LTOs? Beans expose attributes (data) by providing an accessor method (aka getter or get method). Beans also have a public/private setters that set the atributes. It may also contain other methods such as getMemento(), setFromMemento(), validate(), setFromTO(), createTO and getTO(). According the java docs, a TO is basically a bean with an init() and getters. A TO is used to reduce network traffic as well as encapsulate data in a manner that the data cannot be changed after init(). In my own programming needs, I felt that a full-blown TO with getters was too close to a bean. I liked the idea of LTOs and chose to use this type in my current project. The LTO is populated via the init() method - however, rarely - you can instantiate it and then populate later. This only occurs in the read() method of my DAOs. I'll pass in an unpopulated LTO as an argument. If a record is returned, populate the LTO like qryRead.someField = arguments.myTO.someField. That's why I have setFromTO() method option in the bean creator - you can instantiate a bean and then populate it from the corresponding TO. Most of my beans have error and validate methods as well. I usually assume that data from my DB or other persistant data store was valid when entered (your application should validate data right?). I always pass in a TO to my create() and update methods of my DAO - it's simple to call the public CFC scope (THIS) to get data such as: <cfqueryparam value="#arguments.someTO.f_name#" /> The usually use of beans and LTOs in my apps are as follows: Form/URL -> Bean -> Validate/do stuff -> getTo() -> DAO:create() or update() DAO:read() and populates passed in unpopulated TO -> do stuff -> finished or uses setFromTo() to repopulate a bean My LTO is an implementation of the what is in Phil Cruz's Mach-II sample app. Sorry if this post looks simular to a post a few weeks ago on the Mach-II list as I stole bits from there (mostly because nobody objected to my explaination). Best and HTH, .Peter P.s. I've been asked this a lot lately...I think a blog post is in need. Yoda: It comes...soon it will.... P.p.s. I'm no OO guru and still learning...so take my thoughts with a grain of salt... To coin a phrase from Sean Corfield: "OO is hard". -- Peter J. Farrell :: Maestro Publishing blog :: http://blog.maestropublishing.com email :: [EMAIL PROTECTED] Create boilerplate beans! Check out the Mach-II Bean Creator - free download. http://blog.maestropublishing.com/mach-ii_beaner.htm Old Computer programmers never die, they just decompile. ------------------------------------------------------------ You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). CFCDev is supported by New Atlanta, makers of BlueDragon http://www.newatlanta.com/products/bluedragon/index.cfm An archive of the CFCDev list is available at www.mail-archive.com/[email protected] |
- [CFCDev] Form Validation Peter H
- Re: [CFCDev] Form Validation TelegramSam . 4847275
- Re: [CFCDev] Form Validation Cliff Meyers
- Re: [CFCDev] Form Validation Peter H
- Re: [CFCDev] Form Validation Cliff Meyers
- Re: [CFCDev] Form Validation Peter J. Farrell
- Re: [CFCDev] Form Validation Cliff Meyers
- Re: [CFCDev] LTOs (was:... Peter J. Farrell
- Re: [CFCDev] LTOs (... Peter J. Farrell
- Re: [CFCDev] LT... Cliff Meyers
- Re: [CFCDev] LT... Pat Branley
- Re: [CFCDev] LT... Jared Rypka-Hauer - CMG, LLC
- Re: [CFCDev] LT... Bill Rawlinson
- Re: [CFCDev] LT... Peter J. Farrell
- Re: [CFCDev] LT... Bill Rawlinson
- RE: [CFCDev] LT... Dave Merrill
- Re: [CFCDev] Ge... Peter J. Farrell
- RE: [CFCDev] Ge... Kerry
