简体   繁体   English

使用小写字母启动C#类名称

[英]Starting a C# class name with a lower-case letter

I'd like some best-practice advice regarding naming a C# class that interacts with an iSeries web service. 我想了解一些关于命名与iSeries Web服务交互的C#类的最佳实践建议。 I'm thinking either iSeriesServiceProxy or ISeriesServiceProxy, but each have their (probably obvious) problems. 我在想iSeriesServiceProxy或ISeriesServiceProxy,但每个都有它们(可能是明显的)问题。 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服务的功能选择名称,而不是它使用的技术。

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. 因此,即使将它命名为ISeriesServiceProxy也是“正确的”,我也不会选择此名称而是使用ServiceProxyForISeries或类似名称。 This will lead to less confusion with your collegues! 这样可以减少与同事的混淆!

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'. 如果你不热衷于此,我会从类名的开头删除小写'i',因此它被称为'SeriesServiceProxy'。

"iSeries" as in the descendant of the old AS/400 series? “iSeries”和旧AS / 400系列的后代一样? 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. 在这里你应该找到一个合适的大写名字的灵感。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM