|
| 1 | +--- |
| 2 | +id: packages |
| 3 | +title: Packages |
| 4 | +sidebar_label: Packages |
| 5 | +--- |
| 6 | + |
| 7 | +#### The following convention should be followed for package naming: |
| 8 | + |
| 9 | +The prefix of a unique package name is always written in **all-lowercase ASCII letters** and should be one of the top-level domain names, currently **com**, **org**,**edu**, **gov**, **mil**, **net**, or one of the English two-letter codes identifying countries as specified in ISO Standard 3166, 1981. |
| 10 | + |
| 11 | + - Packages are all lower case to avoid conflict with the names of classes or interfaces. |
| 12 | + - Special characters are not allowed while naming packages, only alphanumeric. |
| 13 | + - Avoid reserve keywords |
| 14 | + |
| 15 | +Subsequent components of the package name vary according to an organization's own internal naming conventions. Such conventions might specify on technical aspect or a feature aspect e.g employee, leave, department, project etc : |
| 16 | + |
| 17 | + #### packaging by feature |
| 18 | + |
| 19 | + - com.projectname.employee |
| 20 | + - com.projectname.leave |
| 21 | + - com.projectname.department |
| 22 | + - com.projectname.project |
| 23 | + - com.projectname.utils |
| 24 | + - com.projectname.common |
| 25 | + |
| 26 | + #### packaging by patterns |
| 27 | + |
| 28 | + - com.projectname.controller |
| 29 | + - com.projectname.service |
| 30 | + - com.projectname.models |
| 31 | + - com.projectname.factories |
| 32 | + - com.projectname.utils |
| 33 | + - com.projectname.repository |
| 34 | + |
| 35 | +In some cases, the internet domain name may not be a valid package name. |
| 36 | +This can occur if the domain name contains a hyphen or other special character, |
| 37 | +if the package name begins with a digit or other character that is illegal to |
| 38 | +use as the beginning of a Java name, or if the package name contains a reserved Java keyword, such as "int". |
| 39 | +In this event, the suggested convention is to add an underscore. For example: |
| 40 | + |
| 41 | +| Domain Name | Package Name Prefix | |
| 42 | +|--- | ---| |
| 43 | +|hyphenated-name.example.org | org.example.hyphenated_name | |
| 44 | +|example.int |int_.example | |
| 45 | +| 123name.example.com |com.example._123name | |
| 46 | + |
0 commit comments