I recently ran into a lot of the same head scratching that you are
currently tackling. I'm going to preface this with the fact that I am
relatively new to OO in CF as well and this is by no means gospel!
I started by modeling the domain, that is creating the objects I could
easily identify. In your case, I would begin by modeling a single user,
then creating the more specific objects like worker and manager, then
move on to creating a project and an assignment. After creating each of
the specific objects that model "things" in my app, I then created DAO
objects. Once you have all the pieces, it then becomes a job of how
they fit together. In my case I created two objects to manage aggregate
access and another to manage access to that specific object type; a
gateway and a service object. The gateway is intended to process all
aggregate information on each object, and the service object is used to
interact with the individual object.
Here is a possible object architecture (indented items are composited
objects):
project.cfc - Project Bean
- ManagerArray (will store the manager object(s) of this project)
projectDAO.cfc - Data access object for a project
projectService.cfc - Manages access to the project data (an example
method would be projectDAO.read(project)
- projectDAO
- project
projectGateway - Manages aggregate access to projects
user - Generic user object that contains:
- projectArray
userDAO - Data Access Object for users
userService - generic user access service
- user
- userDAO
userGateway - Manages aggregate access to users
manager extends user - more specific manager object
- WorkersArray
managerDAO extends userDAO - data access object for managers
managerService - manages access to manager object
managerGateway - Manages aggregate access to managers
worker extends user
- assignmentArray
workerDAO - worker DAO object
workerService - manages access to worker object
assignment - specific assignment object
assignmentDAO - DAO object for assignments
assignmentService - manages access to the assignment
assignmentGateway - manages aggregate access to assignments
With this method, once all objects are created and populated with data,
you can access the data in flexible ways. You asked how you could get
the following structure:
Worker
Project1
Assignment1a
Assignment1b
Project2
Assignment2a
Assignment2b
Considering the worker has an array of it's project stored internally
you can loop over that array, and then use the assignment service to
return the assignments for that specific project. Something like:
<!--- get a worker from the worker service --->
<cfset worker = workerService.getWorker(1)>
#worker.getName()#
<cfset projects = workerService.getProjects()>
<!--- loop over the project array contained in the worker --->
<cfloop from="1" to="#arrayLen(projects)#" index="i">
project: #projects[i].getName()# <br>
<!--- get all assignments for this project --->
<cfset assignments =
assignmentGateway.getAssignments(worker.getID(), projects[i].getID())>
assignments: <br>
<!--- output the name of each assignment --->
<cfloop query="assignments">
#assignements.name#<br>
</cfloop>
</cfloop>
I hope this gives you some ideas that will help you move forward. If
anyone else has any input on this type of an architecture, I'd be glad
to hear about it!
Rich Kroll
Application Developer
-----Original Message-----
From: Joelle Tegwen [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 10, 2006 10:06 AM
To: CF-Talk
Subject: In totally over my head with OOP and extends (OT?)
I'm a (soon to be) former ASP programmer with a little training in Java
trying to do OOP as I learn CF and I've got a "how the heck does this
work" question.
I'm happy to go RTFM if I only knew the question I'm asking. So if
there's some FM I should go read just point the way. :) And maybe it's
just totally off topic and I should go to some other list with this
question (or some kind soul will pity me and help me anyway).
I'm learning CF with this little time tracking application. It's got
Manager.cfc (extends User) and Worker.cfc (extends User).
There are Projects, Managers administer Projects and Workers contribute
Effort to meet a given (percent effort) Assignment.
So the way I'm looking at this is that Managers have Projects, but so do
Workers. But a WorkerProject (extends Project) has Assignments (which
have Effort) and a ManagerProject (extends Project) has workers.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240096
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54