Here is an big picture diagram of a DAO architecture I have been inching my way thru.  
I'd imagine you could take this approach for BO as well.

It has gone thru several iterations and more will undoubtedly be made but I thought It 
was worth sharing none the less.

Improvements are always welcome.

Thanks,
Mike







----- Original Message ----- 
From: "Justin Balog" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, December 08, 2003 12:26 PM
Subject: RE: [CFCDev] Why not have DAO in BO?


Hmm, lets say you wanted to initialize the objects instance data  from a
form, or some other mechanism other than the dB?  I have gone with the idea
that the BOs are fairly light weight, they simply package instance data, and
perform very limited validation on themselves.  That way they can be
populated in a verity of ways....form data, dB data, whatever. The DAO in my
apps serves as the go between for the BOs and the Persistence Mechanism.
Does that make sense?  

Justin

-----Original Message-----
From: Gabriel Roffman [mailto:[EMAIL PROTECTED]
Sent: Monday, December 08, 2003 10:25 AM
To: Cfcdev
Subject: [CFCDev] Why not have DAO in BO?


I've read and reread Sean's Mach II article example and am trying to
implement it now.  However, my natural inclination is to have the DAO object
be part of the business object?  In the init method of the BO, I would call
the read method of the DAO.  So my init method of the BO would look
something like this...

<cffunction name="init">
    <cfargument name="objID" type="numeric" default="0" required="false">
    <cfset var instance = structNew()>
 <cfset instance.ID=0>
 <cfset instance.name="default name">
 <cfif val(objID) GT 0>
  <cfset data = DAO.read(arguments.objID)>
  <cfset instance.ID = data.ID>
  <cfset instance.name = data.name>
 </cfif>
 <cfreturn this>
</cffunction>

What do you see as pitfalls of having the DAO be inside the business object
like this?

Gabe Roffman

www.etesters.com


----------------------------------------------------------
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
www.mail-archive.com/[EMAIL PROTECTED]
----------------------------------------------------------
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 www.mail-archive.com/[EMAIL PROTECTED]

Attachment: CFC DAO Architecture.doc
Description: MS-Word document

Reply via email to