What's under the hood? [Ariel Weinstein]

Well, I tried to solicit email from you with any cool ideas you have for Collections, ServiceProcesses, and Diagnostics, but that front has been a bit quiet. Thats quite ok though, because there is something else I would like to touch on today. My main roles right now are those three features, as well as application compatibility between different versions of .Net. Luckily, an issue came up this week that covered both areas very nicely.

I received an email where somebody was trying to understand exactly how ListDictionary works. Specifically, ListDictionary is implemented with a list, and the person wanted to know if objects are placed in the front or rear of the list. After talking with other members of the development team, we decided the answer is that it isn't really useful to document how it is implemented. The reason behind it is that people may start using this information to write code that uses behavior that currently works but is not guaranteed to work (you wouldn't do that though, right?).

For example, somebody might want to test if a key was added to the dictionary. If that person knew that the key was placed at the front of the list, they do something very unwise such as checking the first object in the ICollection returned by ListDictionary.Keys to make sure the last Key was entered. This operation _may_ work if the implementation is done in a certain way, but has little to do fundamentally with how a dictionary is intended to work, which means it could be changed in a later version of the software if the current implementation turns out to be broken/slow/whatever.

So to sum up? If you are trying to figure out how something such as a collection is implemented under the covers, it may be appropriate to try using a different collection altogether. For the question above, it may be much better for the user to simply use a List to ensure that functionality.

However, if you think the documentation is sparse, please send drop a comment here I'm still waiting for some from last week's post!

-Ariel
ArielW@microsoft.com