Friday, July 23, 2004 3:04 PM
pgolde
TreeDictionary vs. OrderedDictionary
I firmly believe that using good names is very important in API design.
Several people have comments on my proposed name of OrderedDictionary for the comparison-based dictionary that uses a balanced binary tree as its implementation. These people feel that TreeDictionary would be a more useful and descriptive name.
I thought to gather some feedback on this. Here's what I see as the arguments the different proposals:
TreeDictionary:
* It's clear how is is implemented. If you are familiar with trees, you'll know the basic performance characteristics.
* Follow's the Java-like naming pattern of having classes describe how they implement the corresponding interface.
* It's more clearly differentiated from System.Collections.Generic.SortedDictionary.
OrderedDictionary:
* The name summarizes the basic differentiator from Dictionary -- it use comparison instead of hash, and maintains key in order.
* The fact that it is implemented with a tree isn't visible through the public interface. You can't see the root, the leaves, etc.
* Users shouldn't really care how it is implemented, only about the public interface and performance characteristics.
* If you aren't familiar with the CS concept of a tree, the name is confusing.
* Follows the STL-like idea of describing what the implementation does, not how it does it. In STL, this same collection is simply called "map".
What do people think?