Arrays v. otherCollections

Ned Konz ned at bike-nomad.com
Mon Apr 28 16:51:43 UTC 2003


On Monday 28 April 2003 09:38 am, Jimmie Houchin wrote:

> When dealing with a known static form like a book, would there be
> any reason to choose something other than an Array?

Yes. Arrays don't grow or shrink.

> #(Book #(Chapters #(Verses #(Text))))
>
> Is there anything I should be aware of when creating
> multi-dimensional Collections?

Yes. Multi-dimensional collections are often a sign of incomplete 
design.

When your data gets this complex, you probably should have objects. 
Why aren't Book, Chapter, Verse all object above?

If you have multi-dimensional collections of data of different kinds 
you almost certainly should be using objects that themselves hold 
collections.

The choice of which collection to use in those objects should depend 
on access patterns.

In the case where you don't have to grow or shrink the collection, an 
Array is probably fine.

-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE



More information about the Squeak-dev mailing list