命名混乱?名为 FlowerGroup 和 FlowerGroups 的对象是否令人困惑?
我正在编写一个程序,我似乎正在创建很多对象,其中一个对象将是单数形式,然后集合是复数形式。例如
销售组 SalesGroups
这会让其他程序员阅读我的代码感到困惑吗?
I'm writing a program and I seem to be creating alot of objects where one object will be the singular form and then the collection is the plural form. eg
SalesGroup
SalesGroups
Is this confusing for other programmers to read my code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不应该令人困惑,事实上,我发现它内容丰富且清晰;除非你有多种类型的集合(蹩脚的例子:假设你有一个数组,还有一个 SalesGroup 的映射,那么 SalesGroups 不会是最好的选择,但你宁愿选择 SalesGroupArray、SalesGroupMap 等)
should not be confusing, in fact I find it pretty informative and clear; unless you have multiple kinds of collections (lame example: suppose you have an array but also a map of SalesGroup, then SalesGroups would not be the best choice but you'd rather pick SalesGroupArray, SalesGroupMap etc.)
我认为这是完全有道理的。不指定集合类型意味着您以后可以自由更改实现,并且客户端不能依赖特定的实现。
I think that makes perfect sense. Not specifying the type of collection means you're at liberty to change the implementation later, and clients can't rely on a particular implementation.
虽然它并不令人困惑,但我认为它很容易被错过。如果我这样做,我会使用更突出的东西,也许是
SalesGroup
和SalesGroupCollection
。While it's not confusing, I think it is very easy to miss. If I were doing this, I would use something that stands out more, perhaps
SalesGroup
andSalesGroupCollection
.对我来说似乎没问题。只需在整个项目中保持您的编码风格即可。
seems OK to me. just maintain your coding style throughout all your project.