Henry, If you don't need the City to tell you what Country it's in, you don't need the reference.
-m Mitchell Rose Senior Web Developer The Church Pension Group 445 Fifth Avenue New York, NY 10016 212.592.8214 -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Henry Ho Sent: Friday, February 20, 2009 4:02 PM To: CFCDev Subject: [CFCDEV] Re: To Reference or not to reference... that is my question Let me try to explain with another example. A Country has many City. So.. let's say I want to create a new City. In order to be a valid city, it has to belong to a Country. However, if the City has no behaviour that requires Country, does it make sense to have City carry a reference to Country? The system, (through use of singleton) must be able to answer which city belongs to which country, but City object itself does not. Thanks, Henry Ho On Feb 20, 12:44 pm, Dan Wilson <[email protected]> wrote: > I have no idea what you are asking. > > > > On Fri, Feb 20, 2009 at 3:38 PM, Henry <[email protected]> wrote: > > > Dear all, > > > Q: Can an object (objectA) has a reference to other object (objectB) > > just for the sake of representing the relationship while none of the > > behaviour of objectA requires objectB? > > > e.g. In a CMS system that manages many sites: a Site has many Page. > > Page has a reference to the Site to specify which site it belongs to. > > However, none of the behaviour/methods of Page requires Site. > > > Is representing the many-to-one relationship (many Page has one > > Site) a valid enough reason to have Page carry a reference to the > > Site object? Or having this reference to Site is actually > > unnecessary? If so, how else to specify that relationship? > > > Here's what I think... agree or disagree? > > > a.) Setting just the ID can represent the relationship without > > reference. But in pure OO fashion, storing siteID in Page seems > > weird, afterall siteID is a PK of the Site table. > > > b.) If the only reason to eliminate the reference to Site is the > > overhead of creating the Site object, then a SiteProxy object sounds > > like a good fit. So, just store a reference to SiteProxy in Page to > > represent the relationship. > > > Thank you all! > > > Henry Ho > > -- > "Come to the edge, he said. They said: We are afraid. Come to the > edge, he said. They came. He pushed them and they flew." > > Guillaume Apollinaire quotes --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CFCDev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cfcdev?hl=en -~----------~----~----~----~------~----~------~--~---
