Re: many-to-many relationships and object design
Re: many-to-many relationships and object design
- Subject: Re: many-to-many relationships and object design
- From: Zach Paine <email@hidden>
- Date: Thu, 17 Jun 2004 22:15:38 -0400
On Thu, 17 Jun 2004 19:39:03 -0600, Todd Ransom <email@hidden>
wrote:
> I have considered creating a relationship class that would act as a
> table (like a relationship table in a RDBMS) but this seemed like it
> would be complicated to implement. I tried storing an array of actors
> in each scene object but then I needed a way for the scene to resolve
> actor ids to actor objects. Since the actor objects only know about
> themselves I put this in the NSDocument subclass. But now I can't
seem
> to think of a reasonable way for the scene objects to know which
> instance of the NSDocument subclass they belong to. I get the feeling
> that I am trying to work my way through a problem that has a fairly
> simple solution if only I had more experience with OO design.
It would seem natural for an actor to contain an array of pointers to
the scene(s) they are in, and for a scene to contain an array of
pointers to the actor(s) in that scene. There doesn't seem to be a
need to differentiate between "actor ids" and "actor objects". You
have an array of actor objects in your NSDocument, and each scene
contains an array of pointers to the appropriate actors. To establish
exactly what actor is where can be as trivial as doing something like
this within your scene class:
[ [ actorArray objectAtIndex:i ] name ];
or to determine if an actor is in a scene:
[actorArray containsObject:anActor];
Hope this helps!
-Zach
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.