> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
> Of Scratch
> Sent: Thursday, August 25, 2005 9:12 AM
> To: [email protected]
> Subject: [CFCDev] All CFCs Extend DAO CFC
> 
> 
> 
> Is it bad practice to have all your DAO CFCs extend a main DAO CFC that
> stores the DSN, UN, PW?

Well... two parts:

1) I think it can be good to have a CFC that specifies standard data-access
information.  In my case I've a single "PersistenceInfo" CFC that is
extended by specific CFCs like "PersistenceInfo_DSN" or
"PersistenceInfo_LDAP" - but these last two are both (via inheritance)
instances of "PersistenceInfo".

I can then set up nice little bundles of information concerning Persistence
entities and my DAOs can determine which type they need/can use (for example
some may only be able to use DSN while others could use DSN, LDAP or File).

The DAOs can choose to validate on only the specific PersistenceInfo child
they need or on any PersistenceInfo CFC and switch between them based on
what they get.

2) I DON'T think it's a good idea to add this to a base DAO class.  For one
thing you're limiting yourself on what you can do: what if you want to add
the capability to use LDAP instead of a DB?  If all the DAOs were getting
their information (and DSN specific information at that) from a root class
this would be difficult at best.

Instead I would rather see the DAO accept, as a single property, a bundle of
persistence information.  Whether you go to the effort to make that a CFC or
just use a struct doesn't matter as much (although a CFC lets you do type
validation on the bundle easily - but it'd be a really simple CFC).

But by funneling all the "system" information via a single property you
leave the possibility open to add/change components of that bundle without
affecting the interface to your DAOs.

Of course this is all just my opinion.  I don't have an OO background so who
knows if I'm close.

If you'd like to see the way I've done this I've published (but not
documented) a lot of my code here:

http://www.depressedpress.com/depressedpress/Content/Development/ColdFusion/
DPLibraries/Index.cfm

The (very simple) PersistenceInfo stuff is in the Utility Package and both
the Framework and Security packages use them (look especially the various
"brokers" which are my DAO).

Again, I'm not sure if any of this is "right" - but it works great for me.

Jim Davis






----------------------------------------------------------
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]


Reply via email to