Question

Do you name a dictionary by the key or the value? I have a dictionary that will hold gradient data and the component:

dictionary[gradient] = component;

Do I name it gradientDictionary or componentDictionary?

Was it helpful?

Solution

That depends, but generally I'd suggest naming by the values. The keys are often just a way to quickly find what you are actually looking for and will be using.

Depending on context, for your specific example, I'd also probably suggest just calling the dictionary components to avoid encoding too much type information in the name.

Licensed under: CC-BY-SA with attribution
scroll top