• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Parent-child Design Pattern
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Parent-child Design Pattern


  • Subject: Parent-child Design Pattern
  • From: Martin Hewitson <email@hidden>
  • Date: Sun, 12 Jun 2011 21:12:25 +0200

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@hidden
WWW: http://www.aei.mpg.de/~hewitson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Parent-child Design Pattern
      • From: Quincey Morris <email@hidden>
    • Re: Parent-child Design Pattern
      • From: Joanna Carter <email@hidden>
  • Prev by Date: Re: Memory Management for an Array
  • Next by Date: Re: Parent-child Design Pattern
  • Previous by thread: Re: Memory Management for an Array
  • Next by thread: Re: Parent-child Design Pattern
  • Index(es):
    • Date
    • Thread