• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Collections [was NSCollectionConroller ?]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Collections [was NSCollectionConroller ?]


  • Subject: Collections [was NSCollectionConroller ?]
  • From: T Reaves <email@hidden>
  • Date: Sat, 28 Feb 2004 13:36:49 -0500

On Feb 28, 2004, at 2:31 AM, Allan Odgaard wrote:

> On 28. Feb 2004, at 1:20, T Reaves wrote:
>
>> Collection semantics. :)
>> [...]
>> Perhaps if/when NSCollection and its subclasses are introduced, so
>> will NSCollectionController.
>
> Do you mean that you would like to see consistent naming in the
> various existing collection classes, or that you want to introduce a
> common (abstract?) super class for these? or perhaps something third?
>
>
All of the above. My following explanation is MY take on things; I'm
not insinuating it is the 'correct' way.

When I see array, I thing of a collection of like items. So you might
have an array of NSString objects, but not an array containing NSString
and NSNumber objects. Array connotes a typed collection.

Then you have a list; an arbitrary, untyped collection of objects that
allow duplicates. Notice I said nothing about ordering. Now we have
set. This to me has a mathematical definition, as a group of untyped
objects were duplication is not allowed.

Lastly, you have the concept of ordered versus unordered. There will
be times when either is appropriate, and times when a very specific one
is required.

All of these have things in common; the ability to iterate over them,
to create sub-collections from them, to combine them with other
collects, to get the contents, to determine membership, etc. This
functionality aught to be described in an NSCollection superclass.

A few places I think NSArray & NSSet fail are: a) ordered sets.
Putting a filter on a set would suffice (and allow for arbitrary
sorting order), but interposing a filter and creating an array is just
too manual. b) no list. Whereas NSArray is used as a list, there is no
way to differentiate which is truly desired. c) no superclass. Where
can a generic 'collection' be used, versus an actual set.

So a class hierarchy might look like the following:

NSCollection
NSOrderedCollection
NSList
NSArray
NSOrderedSet
NSString (couldn't help myself with this one!)
NSUnorderedCollection
NSBag
NSSet
NSOrdering
or some such. NSOrderedCollection could have a setOrdering:
(NSOrdering*) ordering to allow for arbitrary ordering, with the
default being index to the order of addition.

Notice NSArray is a subclass of NSList. Here, the add*: methods are
over ridden to allow adding only one type of object (perhaps defined by
the first object added). There are times when I want a collection, and
I want it clear it is only to hold one type of object.

This aught to all be fairly familiar to any Smalltalk'er.

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.


  • Follow-Ups:
    • Re: Collections [was NSCollectionConroller ?]
      • From: Ondra Cada <email@hidden>
References: 
 >NSCollectionConroller ? (From: T Reaves <email@hidden>)
 >Re: NSCollectionConroller ? (From: Scott Anguish <email@hidden>)
 >Re: NSCollectionConroller ? (From: T Reaves <email@hidden>)
 >Re: NSCollectionConroller ? (From: Allan Odgaard <email@hidden>)

  • Prev by Date: Re: how to create status bar?
  • Next by Date: Re: US / British English Localisations
  • Previous by thread: Re: NSCollectionConroller ?
  • Next by thread: Re: Collections [was NSCollectionConroller ?]
  • Index(es):
    • Date
    • Thread