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.

  1. Class naming: First letter of each syllable word capitalized, for example FieldInfo, Expression, etc.

  2. Regular variables (including variable reference naming in Spring): First word lowercase, then first letter of each subsequent word capitalized, for example: password, primaryFlag

  3. Static variables: All uppercase, multiple words separated by _, for example BOOLEAN_FLAG

  4. Package naming: All lowercase, for example com.joinspider.workdesk

  5. Class names and variable names are name combinations. Multiple nouns are in the same order as Chinese, for example ScriptEngine

  6. Properties can also be adjective + noun

  7. 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.

  8. Methods are verb + name or just verb

  9. Import needs to specify which class to import. Importing the entire package is prohibited

    import java.util.*; // Wrong
    
    import java.util.HashMap; // Correct
    
  10. Test Class names are in the format “Tested Object Class Name + Test”

  11. All Class names for testing or Package testing are in the format “AllTest” or “Package Name + Test”

  12. Method names that generate Objects are in the format “create + Object Name”

  13. Method names for conversion are in the format “to + Object Name”

  14. 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