How to name a HashMap in Java?

后端 未结 9 1661
难免孤独
难免孤独 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:21

    My opinion would be to have it countiesCountOfStateMap or simply countiesOfStateMap since we will be getting the counties count using the State.

    It would be more meaningful to have it like this, so when new person looks into your code atleast he would be aware of what is contained in it.

    But at the end of the day its your decision to have the appropriate name and as @tulskiy mentioned naming the class and variable appropriately is one of the harder things.

    0 讨论(0)
  • 2021-02-01 01:25

    I would call it numCounties or countyCounts.

    0 讨论(0)
  • 2021-02-01 01:25

    Whatever explains it best - In this case stateToCountyMap is ok or else countiesInStateMap can be used.

    0 讨论(0)
提交回复
热议问题