in reply to Array as object property

Two ways to do it, but one is much more sane than the other:

1) Pass a reference of the array in object2 to object1, so it can add it directly.

2) Have a method in object2 that allows you to add to this array; object1 repeatedly calls this function for each object3 it adds

Method 2 is much much much better from the object oriented stand point as it hides the details of object2 from other objects. Say in the future, you decide to replace that array in object2 with a hash for speeding up another part of the process. With Method 2, you only need to modify how to add things via that function, while method 1 requires modifying object1's code to handle the change. Not the best design here.


Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain