Henry,

I'd focus on behavior to help you answer questions like these. Abstract
relationships are there, but the essential is relationships formed around
getting things done - behavior.

Does Site need to operate on an *array* of Page objects to do it's job? If
not, then you don't need a reference to all Page objects in Site. Simple. If
it needs to operate on a single page object, one at a time, perhaps you can
store an array (or a query) of Page Id's so you can easily create the object
when needed.

Does Page sometimes need Site to do it's job. If so, pass a reference to
Site into Page.

You'll get it wrong, in sense that down the line, you'll realize a better
approach in developing operative relationships between objects. You can't
get around making lots of "mistakes" in OO. It's not like learning syntax,
where you can ask a question or study up a bit and start getting it right
from the beginning.

Focus on behavior ... make your mistakes. The faster you make them, the
faster you'll learn.


On Fri, Feb 20, 2009 at 9: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
> >
>


-- 

Nando M. Breiter
The CarbonZero Project
CP 234
6934 Bioggio
Switzerland
+41 76 303 4477
[email protected]

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to