Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ID to Object "pattern"

Status
Not open for further replies.

michaelveloz

Programmer
Sep 20, 2007
1
US
My question is partly to do with mimicking your domain in your software, and partly to do with finding objects that are associated to one another.

My general question is this: If your domain uses id's to relate entities, should you carry those id's into your objects and use those id's to relate and find objects?

For example, if let's say your domain has the notion of "features" (like feature of a Freezer) and let's say the domain has the notion of Respondents who each provide a rating for each feature.

Now assume in the domain, each feature is assigned an id. Then, each respondent's rating carries the id of the feature the rating is for, so that you can tell what ratings are for which features.

Now, if you were modeling this in OO land .. lets say you have your list of feature objects, and you have a list of respondent object. Each respondent object will have a list of that respondents ratings for each feature.

Here's the question: should the respondent rating objects carry the feature ID.. for lookups, etc, or should they actually hold object references to their corresponding feature objects?

Thanks!
Michael
 
They probably need both.

The ID for persisting the object to the database (if needed), and object references (for each of following object relations)

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top