What's a good naming convention for a lookup map/hash?

My vote would be for codeToName in this particular case, and I guess that generalizes. That's not to say that it's the name I would have chosen myself in all cases; that depends a lot on scope, further encapsulation, and so on. But it feels like a good name, that should help make your code readable:

String country = codeToName["SV"];

Looks fairly nice, should be easily understandable by anyone. Possibly change the word "code" to something more precise ("countrycode" would be my next choice).


country_name = countries_by_code[country_code]

It passes the “telephone dictation” test, and also sounds more like natural language.


I like to use plurals for collections.

countryNames

Edit: countryCodes is wrong because you are mapping from a code to a name.