OO Programming with Databases question
So here's my question. It's mainly conceptual. It might be best if I explain in full context of what i'm doing.
I'm reworking the Careers section of my company's website, which lists current job openings and information about these jobs, and allows users to apply to them and people here at work to update the listings on the page. For the main page of it, they want the basic info about current openings to be displayed in a hierarchy of:
Category->Region->Position
Categroy is the type of job (IT work, engineering, adminstrative...), region is where the job is located, and Position is detailed info about the job itself. They have a database set up with a table for each of those three things.
I decided it would be best to create classes for these things as well, so I have a Position class, a Region class (which contains a list of Positions), and a Category class (which contains a list of Regions).
On the main page, only basic information must be displayed, such as Categories with open positions, and maybe region info. Specific information about the positions aren't needed on this main page. So, when I query the database, I don't call for much information about the positions or regions.
Along the same lines, I don't feel it's neccessary to populate the lists of sub-information that Category and Region classes have with new objects, because I don't have all the information for those objects yet. However, I still need, say, my Category class to at least have a list of its regions. But only the *name* of the region is needed, and not all it's info, which makes me think that actually creating a new Region object is unneccesary.
This seems like it might be a common thing to worry about with OO programming and Databases, and I've mulled this over for a bit, and a clear answer hasn't jumped out at me. How should I seperate data and create my classes in this situation?
Any suggestions are appreciated!
|