Package Naming and URL Path Naming Rules

Package Naming and URL Path Naming Rules

  • Package name: Use lowercase uniformly, between dot separators, English words with one and only one natural semantic meaning, use singular form.
  • URL path name: uniformly use lowercase, between slashes, English words with one and only one natural semantic meaning, use singular form.

Most of the time, this is logical and can establish a corresponding relationship with business logic. For example: the package name corresponding to the account opening function should be account.open, not openAccount; other functions under the account module should also be placed under the account package, such as the account cancellation function account.close.

The rules for naming packages and URL paths are similar. There should be a corresponding relationship with the business logic. Following the principle of high cohesion and low coupling, related business modules are placed under a unified level.

Standards in Ali's "Java Development Manual"

[Mandatory] The package name is uniformly lowercase, and there is only one English word with natural semantics between dot separators. The package name is uniformly used in singular form, but if the class name has a plural meaning, the class name can use plural form.

Positive example: the application tool class package name is com.alibaba.ei.kunlun.aap.util, and the class name is MessageUtils (this rule refers to the framework structure of spring)

Package Naming/URL Naming

meaning logical level package name URL address
Futures-Recommendation-Account Opening Futures-Recommendation-Account Opening futures.recommend.account.open futures/recommend/account/open
Futures-account opening Futures-Account-Account Opening futures.account.open futures/account/open
Futures - Cancellation Futures-Account-Close account futures.account.close futures/account/close
Futures - frozen account Futures-Account-Freeze futures.account.freeze futures/account/freeze
Futures-activate account (activate account after first account opening) Futures-Account-Activation (account activation after first account opening) futures.account.activate futures/account/activate
Futures - Account Reactivation (Account reactivation after freezing) Futures-Account-Reactivate (reactivate account after freezing) futures.account.reactivate futures/account/reactivate

Example package structure

  • futures
    • account
      • open
      • close
      • freeze
      • activate
      • reactivate

Guess you like

Origin blog.csdn.net/sgx1825192/article/details/129796255