Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I name a java.util.Map? [closed]

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?

like image 586
Alex B Avatar asked Feb 12 '10 16:02

Alex B


People also ask

How do you name a map?

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.

How do you call a map in Java?

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.

How do you name a Java application?

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.

What is Java Util map?

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.


1 Answers

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.

like image 99
Mark Bolusmjak Avatar answered Sep 29 '22 08:09

Mark Bolusmjak