I was on the train this morning (usual inspiration zone-out) and got to 
thinking about how in various work / business layer i access things like 
DSN details or Hard-Drive locations (ie storage of xml dumps etc).

It occured to me, that maybe an object called PersistStorageBean (or maybe 
even PersistBean) could be an object setup specifically for this.

The overall concept came about when I noticed that in some Models when 
folk(s) use a DAO, they simply feed in DSN information (whether its DSN or 
DSN,DSN_Username,DSN_Password etc). Typically most applications would 
utilise a database, but in some cases its acceptable to simply store 
information inside XML packets on a hard-drive (ie WDDX aswell). This 
could also be mixed, in that in one case it stores information inside a 
database, while in other parts it may want to store information on a 
hard-drive. That or it has the typical Multiple DB DAO setup, where users 
could nominate either to use a SQL storage, XML Storage or <insert your db 
here> storage.

Point is, the DAO concept needs to be the only one that knows what 
questions to ask for storage (ie "whats my DSN? whats my DSN Username (if 
shared hosting)  -OR- Where do i store serialized beans? where do i store 
references etc).

I figured this is where a PersistStorageBean object could play a role, 
here is some example code.

<cfscript>
        var oBlogEntryBean = 
createObject("component","entryBean").init(argumentCollection=arguments);
        var persistStorageMemento = 
this.getSingleton("model.myApp.utility.persistStorageBean").getMemento();
 
instance.getDAOFactory(arguments.persistType).getEntryDAO().create(persistStorageMemento,oBlogEntryBean);
</cfscript>

Now, it could simply use a Memento or a DTO for the getting information in 
and out, but the point is the code above (ie Manager) doesn't have any 
condition logic inside it, so it doesn't really care how information is 
stored away.

The getDAOFactory() determines what type of persist layer this app will 
use (either by passing in an argument or reverting to a default). Based on 
this information, the appropriate DAO is slotted into place, which inside 
that object is where it specifically asks the above questions (ie "if i'm 
a DB, whats my DSN details -OR- If i'm a File Storage Layer, where do i 
put things")

What's folks thoughts on this approach? Is it pattern abuse or will i face 
problems (other then using file hard-drive systems for applications vs 
databases.. but lets just say its a basic blog and its suitable for now)

eg properties inside the PersistStorageBean:

- storageLocation (location on the servers hard-drive to store files into 
via the DAO's)
- datasourceName (or dsn)
- datasourceUsername (or dsn_u)
- datasourcePassword(or dsn_p)
- IsSharedHosting (You could use this property inside your DAO objects to 
determine whether you need to insert the username/password for queries.. 
sharedhosting yes, internal no etc)
- .....
and so on....


Scott Barnes
http://www.mossyblog.com



To unsubscribe from this email please forward this email to [EMAIL PROTECTED] 

This email message is confidential and may be privileged. If you are not the 
intended recipient
please forward the email to [EMAIL PROTECTED] and delete the original.
 
ABN AMRO Morgans Limited and its associates hold or may hold securities in the 
companies/trusts mentioned herein.
Any general advice included in this email has been prepared without taking into 
account your objectives, financial situation or needs.
Before acting on the advice, you should consider its appropriateness or discuss 
with one of our investment advisors.

ABN AMRO Morgans Limited (ABN 49 010 669 726 AFSL 235410) A Participant of ASX 
Group.
A principal member of the Financial Planning Association.

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at 
[EMAIL PROTECTED]

Reply via email to