Project Naming Guide
How to name a project? I’m sure all you coders often feel troubled by this. Here I’ve slightly organized some relatively standard naming rules, mainly for my own reference!
Feel free to supplement everyone :-)
1. Project Name
All lowercase, for example cms, workdesk, jobserver, etc.
2. Java-related Naming
-
Class naming: First letter of each syllable word capitalized, for example FieldInfo, Expression, etc.
-
Regular variables (including variable reference naming in Spring): First word lowercase, then first letter of each subsequent word capitalized, for example: password, primaryFlag
-
Static variables: All uppercase, multiple words separated by _, for example BOOLEAN_FLAG
-
Package naming: All lowercase, for example com.joinspider.workdesk
-
Class names and variable names are name combinations. Multiple nouns are in the same order as Chinese, for example ScriptEngine
-
Properties can also be adjective + noun
-
Constants can use the above rules. If to reflect the concept of multiple constants being a group, they can also be modified with prefixes, for example: VAR_START, VAR_END.
-
Methods are verb + name or just verb
-
Import needs to specify which class to import. Importing the entire package is prohibited
import java.util.*; // Wrong import java.util.HashMap; // Correct -
Test Class names are in the format “Tested Object Class Name + Test”
-
All Class names for testing or Package testing are in the format “AllTest” or “Package Name + Test”
-
Method names that generate Objects are in the format “create + Object Name”
-
Method names for conversion are in the format “to + Object Name”
-
In query methods, “find” should be used as a prefix
3. Property files .properties variable naming
object.a_b_c format, all lowercase, where object is the host, and a_b_c is multiple words separated by underscores.
Example: hibernate.cache.use_second_level_cache, hibernate.cache.provider_class, hibernate.cache.provider_configuration_file_resource_path
4. XML file naming
All lowercase, - symbol is the usage description of the xml, similar to applicationContext which is a conventional naming. For example springmvc-servlet.xml, workdesk-manager.xml, workdesk-servlet.xml, applicationContext-basic.xml, etc. In xml, multiple characters are separated by -, for example param-name, filter-mapping, etc.
5. Regular file naming (jsp, js, img, etc.)
Same as Java regular variable naming conventions
6. Property files properties
Separated by underscores: errors_zh_CN.properties, hibernate_test.properties
7. Database naming:
Table and field naming are all uppercase, multiple words separated by _
8. Package naming conventions
We know that generally companies are named “com.companyname.projectname.modulename…”.
Here “com” actually represents the company’s domain name.
In addition to com, domains are divided into org, com, cn, and many others. org is for non-profit organizations, and com is for commercial organizations.
If you don’t have a domain name, you can start with a self-created unique domain name. The most important thing is actually to prevent conflicts.
References
[1] https://blog.csdn.net/weixin_42618873/article/details/90694514
[2] https://blog.csdn.net/youyaecho/article/details/51179023