c# - 关于英语的问题 : Using plural in the first part of an identifier name

标签 c# language-agnostic domain-driven-design naming-conventions vocabulary

作为一个非英语母语的人,我经常想知道在命名类或对象时在名词短语的初始部分使用复数形式。

例如:

  • 如果我有多个 [streaming] 播放器的接口(interface),将其命名为 PlayersInterface 是很好的英文,而不是 PlayerInterface一个玩家?

  • 如果有处理事件的服务,可以将它命名为EventsService吗?还是 EventService 听起来好得多?

感谢您的帮助!

编辑:

  1. 显然,在 .NET 中,接口(interface)名称将以 I 开头。因此,让我们稍微更改示例并将其命名为 PlayersGateway

  2. 我真的没有另一个名为 PlayerInterface(或 PlayerGateway)的类。如果我只需要一个播放器的界面,这只是我使用的替代名称的一个示例。我认为在同一个项目中同时使用 PlayerGatewayPlayersGateway 很难维护,更不用说对 future 的团队成员不利了。所以请假设没有 PlayerGateway,只有 PlayersGateway

最佳答案

据我了解,您通常应该使用单词的单数措辞。例如,如果您有一个 Car 类,并且您有一个包含许多 Car 类实例的类,您可以将其称为 CarCollection 而不是 Cars

关于c# - 关于英语的问题 : Using plural in the first part of an identifier name,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5030498/

相关文章:

oop - DDD 书,埃里克·埃文斯 : What is meant by "The FACTORY should be abstracted to the type desired rather than the concrete class(es) created."?

c# - SQL - 查询字符串请求

language-agnostic - 调用层次结构的最大深度

exception-handling - 我的域异常应该从应用层抛出吗?

最近/经常联系自动完成的算法?

algorithm - 我怎样才能从语料库中只找到 'interesting' 个单词?

domain-driven-design - DDD/CQRS : Combining read models for UI requirements

c# - slider 大小变化

C# ICodeCompiler - 运行类

c# - 如何限制用户登录?