C# 类名以小写字母开头
我想要一些关于命名与 iSeries Web 服务交互的 C# 类的最佳实践建议。我正在考虑 iSeriesServiceProxy 或 ISeriesServiceProxy,但每个都有其(可能是明显的)问题。前者违反了“类名应以大写字母开头”,而后者看起来像一个接口。我可以为这个班级想出另一个名字,但感觉这个是合适的。哪个(如果有的话)是正确的选择?
I'd like some best-practice advice regarding naming a C# class that interacts with an iSeries web service. I'm thinking either iSeriesServiceProxy or ISeriesServiceProxy, but each have their (probably obvious) problems. The former violates "Class names should start with a capital letter", while the latter looks like an interface. I could just dream up another name for this class, but this is the one that feels right. Which (if either) is the correct choice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
根据 Web 服务的功能而不是其使用的技术来选择名称。
Choose a name based on the function of the web service, not the technology it uses.
我相信您应该选择最能传达班级背后内容的班级名称。因此,即使将其命名为 ISeriesServiceProxy 是“正确的”,我也不会选择这个名称,而是使用 ServiceProxyForISeries 或类似名称。这将减少与同事之间的混乱!
I believe that you should decide for the class name that communicates best what's behind the class. So even if it would be "right" to name it ISeriesServiceProxy, I would not choose this name and rather use ServiceProxyForISeries or similar. This will lead to less confusion with your collegues!
这里并没有真正的“正确”答案 - 就我个人而言,我会将班级的第一个字母大写,无论它是否以“I”开头。如果您对此不感兴趣,我会删除类名开头的小写“i”,因此将其称为“SeriesServiceProxy”。
There isn't really a 'correct' answer here - personally, I would capitalise the first letter of the class regardless of whether it starts with an 'I' or not. If you're not keen on that, I'd drop the lower case 'i' from the start of the class name so it's just called 'SeriesServiceProxy'.
“iSeries”是旧 AS/400 系列的后代吗?这根本不应该是名称的一部分。您对运行服务的计算机不可知。问题是,该服务在做什么?这就是您应该找到正确大写名称的灵感的地方。
"iSeries" as in the descendant of the old AS/400 series? That shouldn't be part of the name at all. You are agnostic to the machine the service is running on. The question is, what is the service doing? That's where you should find inspiration for a properly capitalized name.