In OOP, when to use a Collection of Objects with Properties vs. one Object containing a Collection for each Property?
August 11, 2004 1:23 PM
Subscribe
OOPFilter - How do you decide when to use a Collection of Objects with Properties vs. one Object containing a Collection for each Property? [mi]
That is, when you are going to have a bunch of things with some set of properties, how do you decide whether to:
1. Make an object with the properties in question as its fields, and then create an collection of instances of that object for each of the things in your dataset.
VS.
2. Make on object with a collection for each property, and have the properties of a particular item in your dataset spread across the different collections, at the same index in each collection.
Very simple example: say I have data for a scatterplot. I could either make a Point object with a field for x and y, and create an array of Point instances, or I could have a Points object with an array for x values and an array for y values.
posted by badstone to computers & internet (23 comments total)
posted by badstone at 1:26 PM on August 11, 2004