I think you probably want things the other way around - that is pass in
an object or data into the DAO so that it doesn't care about FileHandler
or ActionHandler.  Caveat: I'm not a trained software engineer so all my
OO learning over the past few years has been this group, experimentation
and outside reading.  I'm still evolving in my thinking.  Others may
have different opinions which I gladly welcome.
 
Maybe a structure like this:
 
DocumentBean (or IBO or Struct - something to hold the instance data)
DocumentManager
DocumentDAO
 
DocumentManager has 
variables.dao
variables.FileHandler
variables.ActionHandler
 
Call DocumentManager.upload()
 
The Upload method:
    1) Uploads the file 
    2) Calls the ActionHandler
    3) Calls the DAO (pass in instance data for processing)
    4) returns success/fail
 
At any point you can try/catch for failure and fork your logic to deal
with that event.  It isn't even necessary to ultimately return
something, but it may be useful for your business logic. This is just
off the top of my head, but I think that keeps things tidy.  Does it
make sense to you? It may be helpful to draw it out on paper and map the
relationships that way.  I often find myself drawing boxes and arrows to
try and get things right.  You could go so far as UML, but I haven't
derived much value from that, myself, but we're a pretty small shop.
 
anthony 
 
 

________________________________

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of J MacKay
Sent: Thursday, March 29, 2007 2:11 PM
To: [email protected]
Subject: [CFCDEV] newbie: needs an opinion on component structure


I'm creating a few cfcs to handle file uploading in an MX6.1 application
and would like some opinions.  Here is an outline of the process: 

A site user uploads a document. The file is saved to a directory on the
server. A record is added to a database table with the file location and
a few other details. Whenever a document is uploaded, information is
written to a history table and an email is sent to a few other users
(The last step is a bit more complex, but thats the basic idea).

I was thinking I should have at least 3 components (and maybe a manager
component as well?).

FileHandler.cfc   - Handle file system operations (ie. upload)
ActionHandler.cfc - Create history record and send emails 
DocumentDAO.cfc   - Create new document record (ie. CRUD operations) 

DocumentDAO would contain a reference to a FileHandler and ActionHandler
instance. So the DocumentDAO component wouldn't have to know anything
about uploads or sending emails.  It would simply call a method in
FileHandler or ActionHandler. Something like this

<cffunction name="create"..>

    <cfset variables.fileHandler.upload(...)>
    <cfquery ..> INSERT INTO Documents ...</cfquery>
    <cfset variables.actionHandler.documentCreated(...)>

</cffunction>

I'm not sure if I'm on the right track with this. So I would appreciate
any opinions.  Hopefully the description wasn't too murky.   



Janet
-------
Still trying to wrap my brain around this OO stuff .. so speak slowly ;)



________________________________

Finding fabulous fares is fun.
Let Yahoo! FareChase search your favorite travel sites
<http://farechase.yahoo.com/promo-generic-14795097;_ylc=X3oDMTFtNW45amVp
BF9TAzk3NDA3NTg5BF9zAzI3MTk0ODEEcG9zAzEEc2VjA21haWx0YWdsaW5lBHNsawNxMS0w
Nw-->  to find flight and hotel bargains. 
You are subscribed to cfcdev. To unsubscribe, please follow the
instructions at http://www.cfczone.org/listserv.cfm

CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com

An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]


You are subscribed to cfcdev. To unsubscribe, please follow the instructions at 
http://www.cfczone.org/listserv.cfm

CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]

Reply via email to