by Darrell Duniam >> Wed, 24 May 2000 0:54:44 GMT
Wanting to create an unordered collection of objects for one of my classes, I was unsure whether to create a Set or an ObjectSet, so I consulted the Support team, who responded with the following:
"The reason the Set abstract class has a membership of Any instead of Object is that one day we intend to support Sets (and dictionaries) of primitive types. So the hierarchy will resemble that of Array, which also has an ObjectArray subclass. The distinction between Set and ObjectSet is really only significant with the prospect of primitive sets in mind.
With that in mind, we would generally recommend that users adopt the practice of subclassing ObjectSet instead of Set, since this is strictly more correct in terms of parametric polymorphism. This could be important if you later wanted to add a generic method that only dealt with Object sets (i.e. specifically excluded primitive sets), for that separation to be possible in the future, user sets should subclass ObjectSets. A similar argument applies to Array and ObjectArray, when defining an array of an 'object type' you can subclass Array or ObjectArray, but subclassing ObjectArray provides that extra level of type separation (between primitive and object arrays)."
darrell.