I¹m pretty sure he meant one DAO per business object (although I could be
wrong ­ you can create a ³generic² DAO with parameterized CRUD methods so
it¹d only have four methods and each would work with any table). Most people
have more or less one DAO per table, but even with 40 or even 100 tables,
that isn¹t so many objects ­ having 100 DAOs in memory is not likely to
become a performance bottleneck ­ neither will instantiating 40 or 100 of
them on a single page load on application start, although if you¹re
concerned, use lazy loading and depending on your dependency chains that may
mean they won¹t all be instantiated on app load.

Best Wishes,
Peter


On 11/4/07 8:32 AM, "Mike Kear" <[EMAIL PROTECTED]> wrote:

> Wow that could end up with pretty humungous sized DAO then ­  if I have 40
> tables on the site, I will have somewhere close to 40 Œcreate¹, 40 Œread¹, 40,
> update, and 40 delete methods, plus all the other ancillary methods like init
> and setservice, etc that set it all up and make it work.
>  
> In fact I just counted the tables in the site I¹m working on at the moment and
> there are currently 47 tables on that database, and the task I¹m working on
> now will require an additional 6 tables.
>  
> A CFC with 160-170 methods doesn¹t sound too workable to me.     Do you
> honestly have only one DAO for your whole web site??   I was working on the
> assumption that I should have more-or-less a DAO for each table.    Not
> exactly 1-1 relationship because sometimes it¹s easier to have multiple tables
> worked by one DAO, but 47 of them??  Really?
>  
> Cheers
> Mike Kear
> Windsor, NSW, Australia
> 0422 985 585
> Adobe Certified Advanced ColdFusion Developer
> AFP Webworks Pty Ltd
> http://afpwebworks.com <http://afpwebworks.com/>
> Full Scale ColdFusion hosting from A$15/month
>  
>  
>  
>  
>  
> 
> 
> From: [email protected]
> [mailto:[EMAIL PROTECTED] On Behalf Of Derek P.
> Sent: Sunday, 4 November 2007 1:07 PM
> To: [email protected]
> Subject: [coldspring-dev] How do I inject a userbean into a DAO?
>  
> 
> When you say "a whole bunch of singleton DAOs", what do you mean? You should
> only ever create one singleton DAO for your *entire* application.
> 
>  
> 
> - Derek
> 
>  
>  
> 
> On Nov 3, 2007, at 3:44 PM, Mike Kear wrote:
> 
> 
> Brian, Please don¹t ask me that.  You¹re knowledgeable about OOP techniques,
> I¹m only just learning.  Instead of asking me a question like that, with an
> implied criticism embedded in it, why don¹t you just suggest a better way
> instead.
>  
> In my view, there are two things that make OOP so difficult to understand for
> people who learned coldfusion in the procedural school ­ the esoteric
> arguments back and forth and the huge pile of technical terms.  I even get the
> feeling that there are some people that just make up their own technical terms
> and use them as though we¹re all supposed to know what they are and we must be
> dummies if we don¹t.    There is one leading blogger in the CF world who makes
> a LOT of statements about OOP but I have to confess that in spite of reading
> at least 50 of his posts, there isn¹t a single one that I understood.  He
> might as well have been posting in  Latin for all the good it did me.
>  
> So why I would do it the way I did?
>  
> I figured it was wasteful of resources to just create a whole bunch of
> singleton DAOs on the off-chance that someone might need to use them.   I
> thought a better approach was to instantiate the DAO when someone went to the
> area of the admin module that is going to require this DAO.    I instantiated
> the DAO at the top of the page that requires it, and reused it muitiple times
> down the page.
>  
> Somene else suggested I just access the session.userbean as and when I
> required it, directly from the DAO.   I thought that was BAD BAD BAD.  I
> thought the notion of encapsulation meant no cfc should have to look outside
> itself for anything.  I thought the DAO should be given anything it needs to
> know.    Well in this case,   any cfc modifying the database in any way has to
> have a stamp on the record it changes or adds. .     I need to stamp it with
> the time (can¹t use getdate() in the database because that¹s not Australian
> Eastern Standard Time ­ so I pass in the current AEST) and the ID of the user
> making the change.
>  
> So that¹s the problem I¹m trying to work out Š   how do I inject the userID
> into the DAO so it can use it?
>  
> I¹m afraid I¹m still not too sure how I persuade Coldspring to give me a DAO
> initialised and ready to use, complete with the userid and time (I normally
> use request.austime ­ a variable I create in the OnRequest() method of the
> application.cfc
>  
> Cheers
> Mike Kear
> Windsor, NSW, Australia
> 0422 985 585
> Adobe Certified Advanced ColdFusion Developer
> AFP Webworks Pty Ltd
> http://afpwebworks.com <http://afpwebworks.com/>
> Full Scale ColdFusion hosting from A$15/month
>  
>  
>  
> 
> 
> From: [email protected]
> [mailto:[EMAIL PROTECTED] On Behalf Of Brian Kotek
> Sent: Sunday, 4 November 2007 4:46 AM
> To: [email protected]
> Subject: [coldspring-dev] How do I inject a userbean into a DAO?
>  
> A more fundamental issue is: why would you want to create a new instance of
> the DAO on every request instead of using it as a Singleton?
> 
> 
> 
>  
> 


Reply via email to