Site: instance cached in application scope, stores application wide data like
navigation, generates breadcrumbs from navigation, etc
Page: uses cached instance data in Site to generate page specific navigation,
breadcrumb, and contentProperties for that page
Note your comment here "uses cached instance data in Site" - that implies that Page has a relationship with Site (a Page belongs-to a Site).
ContentItem: uses the contentProperties from Page to determine which specific
ContentObject to instantiate
And the same applies here: ContentItem has a relationship with a Page (but it's a different relationship, I think, to the one above - more below).
Another version of the question is this: Site is a container of PageS, and Page is a
container of ContentItemS - but to make composition work in the sense that each of
these depends on it's parent container, it seems the only way is to pass an instance
of Site inside Page and to pass an instance of Page inside ContentItem - and that
seems backwards to me.
Look at the relationships outlined above - the Site needs to tell the Page "Hey, you belong to me" so that the Page knows which Site instance to interact with. In that case, I think it's perfectly reasonable for the Site to instantiate a Page and pass 'this' into that new page instance so that the Page knows about the Site.
Now, for the ContentItem, it only needs to know about the Page when rendering I suspect so the Page would pass 'this' to the render() method of the ContentItem instance.
As it now stands, i'm breaking encapsulation in Page by accessing thisSite via the
application scope (or am I? I'm not sure):
Yes, you are.
Remember that objects can only collaborate when they know about each other in some way. Passing references to objects back and forth is usually how that is achieved. If the relationship is meant to last for the lifetime of the instances, pass a reference in during construction / initialization. If the relationship is transient - only lasts for the duration of a method call - pass the reference into the method call.
Also bear in mind that this stuff typically gets easier when you introduce one or more "manager" objects and let those manage the relationships between the other objects.
Hope that helps?
Sean A Corfield -- http://www.corfield.org/blog/
"If you're not annoying somebody, you're not really alive." -- Margaret Atwood
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
