I have my objects divided into BO, DAO, Gateway and Manager Object. Many
of my objects are composed of other objects. For instance I have a User
object which is composed of a Person object and an array of Company objects
they sponsor. I'm trying to figure out the best place to load my Person
object from the database when I instantiate the User.
In my UserManager I do the following
<cffunction name="load" returntype="objects.user" hint="I load a
user into memory" >
<cfargument name="person_id" type="numeric" hint="I am the
person_id of the user">
<cfset var myUser =
createObject("component","objects.user").init() /> <!--- returns a blank
User Object --->
<cfset myUser.setPerson_id(arguments.person_id)>
<cfset variables.userDAO.read(myUser) /> <!--- loads some data
such as their security profile --->
<cfreturn myUser />
</cffunction>
Now, I need to load the person information from the database. Ultimately
the code that knows how to do this is in the personDAO. I have a method
that returns a Person object from the person_id in my personManager (which
is instantiated in the application scope). It could be called with the
following:
application.personManager.getPersonByPersonId(arguments.person_id)
Should I call this method in the UserManager above, in the UserDAO's read
method or in the User object's setPerson_id() method?
Should my UserManager, UserDAO or User object know about the personManager
in the application scope or should I just go ahead and instantiate it
locally in the method or in the variables scope?
Suggestions?
Jason Cronk
[EMAIL PROTECTED]
----------------------------------------------------------
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]