Dear List,

This is a question about choosing the correct design pattern for a particular 
application. This application is generic enough that I can describe it by a 
simple parent-child model.

Suppose I have a model object Parent which contains an array of Child objects.

Then I have a ParentView object and a corresponding ParentViewController. The 
controller has a reference to the Parent and to the ParentView and so can act 
as a data source for the view.  So far, so good.

What I'm unsure about is, how to deal with the children objects. I will, in 
principle, have a ChildView. This raises some questions:

1) Should I have a ChildViewController class?
2) Where do I keep the array of ChildView classes? In the ParentView? And how 
do I ensure that each ChildView is associated with the appropriate Child 
object? 
3) If I do have a ChildViewController class, where should I keep the array of 
these? In the ParentViewController? 

I can see a complicated spagehti system arising here. Suppose I don't only have 
a Parent-Child system, but a deeper tree (A contains an array of B, each B 
contains an array of C, etc), how should one extend the scheme?

I'm guessing this is a generic enough situation that there exists a 
best-practice for handling it. For some reason, I can't arrive at it myself, so 
far. Any hints, keywords or clues would be well received.

Best wishes,

Martin

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
    Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: [email protected]
WWW: http://www.aei.mpg.de/~hewitson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to