How to name a HashMap in Java?

后端 未结 9 1659
难免孤独
难免孤独 2021-02-01 00:55

This might be a silly question, but I have never found a satisfying way to name a variable of type HashMap in Java. For example - lets say I have a

9条回答
  •  时光说笑
    2021-02-01 01:07

    I found a great case for countiesByState here:

    valuesByKeys, as in teamsByCaptains. If you're going to include both key and value, this seems to read best. At a high level, you can read it as just "teams", so anything that's performed on it is being performed on teams. The "byCaptains" prefix reads as it should do: a less significant qualifier that follows the teams around to help someone understand the structure if they need to.

    This also allows you to access a value in a JSP with the nice notation countiesByState[myState].

提交回复
热议问题