CodeSOD: The Key to Using Dictionaries

This post was originally published on this site

The Daily WTF

It’s easy to use dictionaries/maps to solve the wrong kinds of problems, but deep down, what’s more elegant than a simple hashed map structure? If you have the key, fetching the associated value back out happens in constant time, regardless of the size of the map. The same is true for inserting. In fact, hash maps only become inefficient when you start searching them.

Concetta recently started a new job. Once upon a time, a developer at the office noticed that the user-facing admin pages for their product were garbage. They whipped up their own internal version, which let them accomplish tasks that were difficult, time-consuming, or downright impossible to do in the “official” front end. Time passed, someone noticed, “Hey, this is better than our actual product!”, and suddenly the C# code that just lived in one folder on one developer’s machine was getting refactored and cleaned up into

To read the full article click on the 'post' link at the top.