包名中的单词应该怎么分开?以下哪项是正确的?
How should one separate words in package names? Which of the following are correct?
com.stackoverflow.my_package
(Snake Case
使用下划线)com.stackoverflow.my-package
(Kebab Case
使用连字符)com.stackoverflow.myPackage
(骆驼案例
)com.stackoverflow.MyPackage
(Pascal Case
)com.stackoverflow.my_package
(Snake Case
using underscore)com.stackoverflow.my-package
(Kebab Case
using hyphens)com.stackoverflow.myPackage
(Camel Case
)com.stackoverflow.MyPackage
(Pascal Case
)一般标准是什么?
以下是官方命名约定文档的规定:
Here's what the official naming conventions document prescribes:
唯一包名的前缀总是用全小写的ASCII字母写的,应该是顶级域名之一,目前是com
、edu
,gov
、mil
、net
、org
或用于标识国家/地区的英文双字母代码之一ISO 标准 3166,1981.
Packages
The prefix of a unique package name is always written in all-lowercase ASCII letters and should be one of the top-level domain names, currently
com
,edu
,gov
,mil
,net
,org
, or one of the English two-letter codes identifying countries as specified in ISO Standard 3166, 1981.
软件包名称的后续组成部分根据组织自己的内部命名约定而有所不同.此类约定可能会指定某些目录名称组件是部门、部门、项目、机器或登录名.
Subsequent components of the package name vary according to an organization's own internal naming conventions. Such conventions might specify that certain directory name components be division, department, project, machine, or login names.
com.sun.eng
com.apple.quicktime.v2
edu.cmu.cs.bovik.cheese
请注意,上述文档未指定顶级域前缀之后的任何内容.JLS 也同意这一点,举了以下例子:
Note that in particular, anything following the top-level domain prefix isn't specified by the above document. The JLS also agrees with this by giving the following examples:
com.sun.sunsoft.DOE
gov.whitehouse.socks.mousefinder
com.JavaSoft.jag.Oak
org.npr.pledge.driver
uk.ac.city.rugby.game
以下摘录也是相关的:
在某些情况下,互联网域名可能不是有效的软件包名称.以下是处理这些情况的一些建议约定:
In some cases, the internet domain name may not be a valid package name. Here are some suggested conventions for dealing with these situations:
这篇关于Java包名称中单词分隔符的约定是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!