问题描述
我对CamelCase有疑问。假设你有这个缩写:联合国教科文组织=联合国教育,科学及文化组织。
I have a doubt about CamelCase. Supose you have this acronym: Unesco = United Nations Educational, Scientific and Cultural Organization.
code> unitedNationsEducationalScientificAndCulturalOrganization
You should write: unitedNationsEducationalScientificAndCulturalOrganization
但是如果你需要写首字母缩写呢?例如:
But what if you need to write the acronym? Something like:
getUnescoProperties();
是这样写的吗? getUnescoProperties()OR getUNESCOProperties();
感谢您的时间!
推荐答案
某些微软已经写了 camelCase
是:
不要在标识符或参数名称中使用缩写。如果您必须使用缩写,请使用驼峰大小写,其中包含超过两个字符的缩写,即使这与该缩写的标准缩写矛盾。
Do not use abbreviations in identifiers or parameter names. If you must use abbreviations, use camel case for abbreviations that consist of more than two characters, even if this contradicts the standard abbreviation of the word.
总结:
-
当您使用两个字符长度的缩写或首字母缩写时,
When you use an abbreviation or acronym that is two characters long, put them all in caps;
当首字母缩写超过两个字符时,请使用大写字母表示第一个字符。
When the acronym is longer than two chars, use a capital for the first character.
因此,在您的特定情况下, getUnescoProperties()
是正确的。
So, in your specific case, getUnescoProperties()
is correct.
这篇关于CamelCase中的首字母缩略词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!