为什么 Hashtable 不是 PascalCase?
我强烈尝试遵循编码风格的一般规则。但是当我查看 .NET 时,我发现某些类与 PascalCasing 规则不匹配。其中之一是Hashtable
,另一个我记得的是Stopwatch
。我想还有更多我不记得了。
是否有理由为这些类保留 PascalCasing 规则?
I strongly try to follow general rules in coding styles. But when i look at .NET, i see that some of classes doesn't match PascalCasing rules. One of them is Hashtable
and the other one which i remember is Stopwatch
. I think there are more which i don't remember them.
Is there a reason to leave PascalCasing rules for those classes ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
因为它们都是字典单词。
您可能需要哈希表的技术词典,但 stopwatch 是一个合法的词。
PascalCasing 适用于将不同单词组合到类名称(* 等)的情况,它与单词的语言起源无关。
Because they are both dictionary words.
You probably need a technical dictionary for hashtable, but stopwatch is a legitimate word.
PascalCasing is for cases where you combine different words to the name of your class (* and such), it isn't concerned with the linguistic origin of the word.
这主要是旧代码,而不是有意为之。有些人会称之为错误。 Imo 秒表的大小写正确(秒表与哈希表,注意空白)。
有趣的是:javas Hashtable 也不是 PascalCase,而新的 HashMap 是(这里我确信这是一个错误,正如 josh bloch 在 effective java afaik 中所说的那样)
Thats mostly old code and not by purpose. Some would call it a mistake. Imo Stopwatch is correctly cased (stopwatch vs hash table, notice the blank).
Funny note: javas Hashtable is not PascalCase either while the new HashMap is (here im sure it was a mistake as josh bloch says so in effective java afaik)
它不是一个“哈希表”,而是一个“哈希表”(据我所知),因此该单词的 PascalCasing 将是准确的。 “秒表”也一样。不过哈希表可能是错误的。
It is not a "hash table" but a "hashtable" (as far as I know), so the PascalCasing of that word would then be accurate. Same for "stopwatch". Could be wrong about hashtable though..