Showing posts with label key. Show all posts
Showing posts with label key. Show all posts

Thursday, January 3, 2013

Indexes and Keys

In any programming language, the developer typically has a choice between two collection types — a list or a dictionary. They may be called something similar, depending on the language — array and hash-map for example. The list uses an index to access a given item in the collection while the dictionary uses a key. A key could be a number, or some other primitive construct in the language, but they're usually strings. There is one interesting distinction between indexes and keys. Indexes are allocated by the list whereas keys have to be dreamed up by the programmer. This is both good and bad. Good because keys are strings based on some concept. Indexes, by contrast aren't so intuitive to the developer when they need to look something up later. Should we just stick with dictionaries in our code, or our we introducing some hidden issues?