While designing part of a .NET object model today, I was writing some code for a
class indexer.
One feature I thought would be cool is the ability to use a string to specify
the index of my collection. My first hack at it seemed quite inefficient - loop through each
object in the underlying list to match names. This would be what Joel Spolsky
refers to as
Shlemiel the painter's algorithm...no good. So my first thought was to use a
Hashtable to relate names to objects. Then I said to myself, "self....I wonder
how Microsoft does this for columns in a row for a DataSet?" So I broke out the
ever-faithful
Reflector tool to take a look. Here are the results...