大写缩写的命名约定 [英] Naming convention for upper case abbreviations

查看:182
本文介绍了大写缩写的命名约定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否应该调用返回XML流的方法

Should a method that returns an XML stream be called

public Stream getXmlStream();

或者

public Stream getXMLStream();

您对此有何看法?什么被认为是最佳做法?

What's your opinion about that? What's considered best practice?

推荐答案

没有一个正确答案。此 wiki 摘录非常有用:

There is no one correct answer. This wiki extract is helpful:


编程标识符通常需要包含缩写词和首字母
,它们已经是大写的,例如旧的HTML文件。通过使用标题案例规则类比
,自然骆驼案例渲染将使用
缩写全部为大写,即oldHTMLFile。但是,
当两个首字母缩略词一起出现时这种方法是有问题的(例如,
解析DBM XML将变为parseDBMXML)或者当标准
强制要求降低驼峰的情况但名称开头时缩写
(例如SQL server将成为sQLServer)。出于这个原因,一些
程序员更喜欢将缩写视为小写
单词并写入oldHtmlFile,parseDbmXml或sqlServer。

Programming identifiers often need to contain acronyms and initialisms which are already in upper case, such as "old HTML file". By analogy with the title case rules, the natural camel case rendering would have the abbreviation all in upper case, namely "oldHTMLFile". However, this approach is problematic when two acronyms occur together (e.g., "parse DBM XML" would become "parseDBMXML") or when the standard mandates lower camel case but the name begins with an abbreviation (e.g. "SQL server" would become "sQLServer"). For this reason, some programmers prefer to treat abbreviations as if they were lower case words and write "oldHtmlFile", "parseDbmXml" or "sqlServer".

这篇关于大写缩写的命名约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆