Naming conventions of composed package names

taboubim :

I want to create a package named form validator.

Is it better to write

  • form_validator,
  • formValidator or
  • formvalidator?

I want to mention that I want to avoid form.validator. And that form-validator is forbidden.

Tim Biegeleisen :

From the documentation on package naming convention:

Package names are written in all lower case to avoid conflict with the names of classes or interfaces

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:

if the package name begins with a digit or other character that is illegal to use as the beginning of a Java name, or if the package name contains a reserved Java keyword, such as "int" ... the suggested convention is to add an underscore.

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.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=441641&siteId=1