问题描述
我想创建一个名为 form validator
的包.
I want to create a package named form validator
.
写的更好吗
form_validator
,formValidator
或formvalidator
?
我想提一下,我想避免 form.validator
.而那个 form-validator
是禁止的.
I want to mention that I want to avoid form.validator
. And that form-validator
is forbidden.
推荐答案
来自 关于包命名约定的文档:
包名全部小写,避免与类名或接口名冲突
所以这会给你留下以下两种可能性:
So this would leave you with the following two possibilities:
form_validator
formvalidator
其实文档也明确了下划线在出现在包名中时起到了特殊的作用:
Actually the documentation also makes it clear that underscore plays a special role when it appears in package names:
如果包名以数字或其他字符开头,作为 Java 名称的开头是非法的,或者包名包含保留的 Java 关键字,例如int"……建议的约定是添加下划线.
因此,仅在特殊情况下才建议使用下划线,您的命名问题似乎不属于这种情况.所以我推荐 formvalidator
作为包名.
So, underscore is suggested only in special cases, into which your naming problem does not seem to fall. So I would recommend formvalidator
as the package name.
这篇关于组合包名称的命名约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!