Joelle,

It can take a while to get your head wrapped around OO. If you haven't read any introductory books, i'd definitely start there. That said, once you begin to understand the theory of it, you'll need to figure out how to practically apply it, and specifically in CF.

My number one tip is to keep your feet firmly on the ground. Stay practical. It's easy to imagine all kinds of Objects in your problem domain in the beginning and wonder how they are all related. Composition, Inheritance, Has A, Is A ...  Managers may own (have) Projects and Projects have Managers and Workers and Managers have Workers and Workers have Managers AND Assignments. How the hell do you model THAT??? It seems like a tangled mess.

Stay on the ground and take it one step at a time. When your application is editing a Project, is it editing a Manager at the same time? If the answer is no, then you most likely don't need to build that relationship into your model. Especially when you are just beginning. Use a Gateway Object (ManagerGateway) to fetch the Manager Names and ID's for your form, and take that foreign key and use your ProjectDAO to persist it in your database.

So for this little piece of your app, where you edit/add Projects, i'd use these objects:

Project - a bean to hold and pass around your Project data

ManagerGateway - a gateway object that just returns queries ...

ProjectDAO - an object specifically for persisting Projects to the database, with CRUD methods create, read, update, and delete.

There are more sophisticated approaches, but this would be a simple outline to follow to get you started. Beans, Gateways, and DAO's.

You would get the data for your reports from a Gateway. In essence, a Gateway simply wraps your queries in a function and makes it available to your whole application from one place.

AssignmentGateway.cfc could have a theoretical method called "getMyReport()" that returns a query that joins your Worker, Manager, and Assignment tables with an appropriate where clause. getMyReport could also take an argument, or several arguments (similar to passing an attribute into a custom tag) that modify the where clause of your query.

Joe Reinhart has some excellent tutorials on OO in CF on his site, http://clearsoftware.net/ (once he gets it back up again - you'll need to wait a day or so ... ).

HTH ... Nando

Joelle Tegwen wrote:
someone on cf-talk said this would be a better place to go for an OO type question. I'm new to CF and I want to learn how to do OO as I learn CF so that I don't carry over my bad habits from my ASP days. (I gave it up. I swear!)

I'm not sure how to handle a situation. Does it go in the model? Does it go in a custom tag?

I'm gearing up with a simple time tracking application for developers working on different projects.

Managers own Projects (many to many)
Workers are assigned to Projects (many to many via Assignments)
Assignments (Worker, Project, StartDate, Percent Effort) are completed by Effort (Assignment, WorkDate, regEffort, otEffort)

I've got all of the data entry done. Now I'm working on the report.

I figure most of the time, people are just interested in the summary. "How is this worker doing on Working the appropriate PercentEffort for this Project?"

So it would be something like this:
Worker
   Project
      Assignment (start date, percent effort)
         totalRegEffort   totalOTEffort   %Effort   HoursOver/Short


There are also times I want to display all of the information
Worker
   Project
      Assignment (start date, percent effort)
         regEffort           otEffort            %Effort
            ..                        ..                        ..
            ..                        ..                        ..
            ..                        ..                        ..
         totalRegEffort   totalOTEffort   %Effort   HoursOver/Short


I'm thinking totalRegEffort, totalOTEffort, etc are more efficiently retrieved from the database, right?

So does Assignment.cfm have getTotalRegEffort, getTotalOTEffort, etc? do I do this in a custom tag by looping the effort?

Sorry if this is really basic, I'm still trying to wrap my head around this.

Thanks
Joelle


----------------------------------------------------------
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).

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





--


Aria Media Sagl
CP 234
6934 Bioggio
Switzerland
www.aria-media.com


Reply via email to