I have a java.util.Map
that maps from a logical name to a set of parameters to use with that name.
Map<String,Parameters> howShouldINameThee = ...;
What is the best name for this map?
Should I go simple and just call this parameters
or parametersMap
?
Do I include information about the key in the name like paramtersByName
so that how to use the String
key is more obvious?
Most topographic maps are named for the most centrally located, well-known, and/or largest community identified on the map. If the community for which the map should be named falls on two or more maps, a directional term might be used such as East and West.
Inserting Elements Into a Java MapTo add elements to a Map you call its put() method. Here are a few examples: Map<String, String> map = new HashMap<>(); map. put("key1", "element 1"); map.
Interface names should be capitalized like class names. Methods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized. Except for variables, all instance, class, and class constants are in mixed case with a lowercase first letter.
util package represents a mapping between a key and a value. The Map interface is not a subtype of the Collection interface. Therefore it behaves a bit differently from the rest of the collection types. A map contains unique keys.
A Map maps something to something else.
I like to use names like uidToPerson
. "To" being the shortest unambiguous way I can think of to show that I have a map.
Edit:
I'll add that I prefer to have the map named this way, because "key" and "value" appear in that order in the name. As opposed to valueByKey
. In mapping operations, the key comes first. You put(key, value)
or get(key)
that gives a value.
Of course this is a matter of personal preference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With