欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

java util map,我应该如何命名java.util.Map?

发布时间:2023/12/4 编程问答 61 豆豆
生活随笔 收集整理的这篇文章主要介绍了 java util map,我应该如何命名java.util.Map? 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

I have a java.util.Map that maps from a logical name to a set of parameters to use with that name.

Map 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?

解决方案

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.

创作挑战赛新人创作奖励来咯,坚持创作打卡瓜分现金大奖

总结

以上是生活随笔为你收集整理的java util map,我应该如何命名java.util.Map?的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。