[Goodie] OrderedSet and OrderedDictionary

Boris Gaertner Boris.Gaertner at gmx.net
Wed Jun 11 20:39:09 UTC 2003


Derek Brans <brans at nerdonawire.com> wrote:

> I implemented OrderedSet based on Set.
>
> Then I just copied Dictionary, renamed it OrderedDictionary and made its
superclass OrderedSet
>
> Not tested.  If you find any errors and make changes, please send me
feedback.


Hello Derek,

in OrderedDictionary you have this method:
collectorType

 ^TcMapType from: self


TcMapType is not part of the standard image (3.4).
There are no senders of collectorType. Is it possible
that you woked with an image that has some add-ons
and that you unintentionally copied this method?

You copied also the method inspect and that is not a good idea:
The DictionarInspector cannot show the structure of
an OrderedDictionary. I think you should delete
inspect, inspectWithLabel:, inspectformsWithLabel,
inspectorFields.

Attached you find a class with a few tests (Yesterday Daniel
convinced me that we should have tests.)
To run the tests, you
1. file in the change set.
2. Open a workspace, type 'TestRunner open', select that
   text and execute it with do it.
3. A window appears. Search the test case 
   'OrderedSetTests', select it and press the button 'RUN'

Here are my impressions: 

Seven tests (from a total of eight tests) are successful, one is
not.

OrderedDictionary seemingly does not use the instance variable
order. That is why testOD4 fails.


The printString of a nonempty OrderedDictionary does not show
the elements. The reason is that 
Collection>>printElementsOn:  uses  the method  do:
and OrderedSet>>do: iterates over the instance variable  order.

Test method  test3 compares two OrderedSets that contain the
same elements in different order. These two OrderedSets are
considered to be equal. That is entirely possible, but other
definitions of equality are equally possible. A statement in the
class comment could be helpful. 

Please don't be disappointed that I found points that  should be
checked and possibly reworked. You asked for opinions and that
is what we all should do from time to time. 

Greetings, Boris




-------------- next part --------------
A non-text attachment was scrubbed...
Name: OrderedSetTests.1.cs
Type: application/octet-stream
Size: 4298 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20030611/3cbe6890/OrderedSetTests.1.obj


More information about the Squeak-dev mailing list