I'm not sure why you would want to carry a reference to an object if it wasn't going to be used, just for the sake of having the object relationship...
Following the last series of conversations on this list, my advice would be to not think too deeply into the issues you asking questions about, and to use your best judgment... Think logically and most likely you will end up with a correct solution. If not, that's ok, its part of learning, just go back and refactor. JAlpino -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Henry Sent: Friday, February 20, 2009 3:38 PM To: CFCDev Subject: [CFCDEV] To Reference or not to reference... that is my question 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 "The sender believes that this E-mail and any attachments were free of any harmful and malicious code or defects when sent. The sender is not liable for any loss or damage arising in any way from this message or its attachments. Confidentiality Note: This e-mail is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. Dissemination, distribution or copying of this e-mail or the information herein by anyone other than the intended recipient, is prohibited. If you have received this e-mail in error, please inform the sender, and destroy the original message and all copies." --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
