Set vs ObjectSet

Discussions about design and architecture principles, including native JADE systems and JADE interoperating with other technologies
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Set vs ObjectSet

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:21 am

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.

Return to “Design and Architecture”

Who is online

Users browsing this forum: No registered users and 19 guests

cron