Skip to content

Commit 9692e81

Browse files
add content for package,classes,variables
1 parent 31eb206 commit 9692e81

File tree

5 files changed

+75
-19
lines changed

5 files changed

+75
-19
lines changed

docs/java/classes.md

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,34 @@ sidebar_label: Classes
66

77
#### The following convention should be followed for `class` naming:
88

9-
* Class names are generally nouns, in title-case with the first letter of each separate word capitalized. e.g.
10-
- **LeaveController**
11-
- **EmployeeRepository**
12-
- **AttendanceRecord**
13-
9+
* Class names are generally nouns or nouns phrases, in title-case with the first letter of each separate word capitalized or **UpperCamelCase**. e.g.
10+
- **LeaveController**
11+
- **EmployeeRepository**
12+
- **AttendanceRecord**
13+
14+
* Test classes are named starting with the name of the class they are testing, and ending with Test. For example,
15+
- **LeaveControllerTest**
16+
- **AttendanceRecordTest**
17+
18+
* Class name should be designed with single responsibility principle, self descriptive and self documenting.
19+
20+
* Classes on various application layers should be suffixed with terms as given below
21+
- Controller
22+
- LeaveController
23+
- ReportController
24+
- Service
25+
- EmployeeService
26+
- LeaveCalculator
27+
- ReportManager
28+
- Models
29+
- Leave
30+
- Employee
31+
- Balance
32+
- Report
33+
- Utils
34+
- ExceptionUtils
35+
- ReportBuilder (*follows builder pattern while generating report*)
36+
- HTMLParser (*cases which includes acronyms, should be written as it is.*)
37+
- Repository/DAO
38+
- EmployeeDao
39+
- LeaveRepository

docs/java/files.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

docs/java/packages.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ sidebar_label: Packages
66

77
#### The following convention should be followed for package naming:
88

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, edu, gov, mil, net, org, or one of the English two-letter codes identifying countries as specified in ISO Standard 3166, 1981.
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
1014

1115
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 :
1216

13-
14-
#### packaging by feature
17+
#### packaging by feature
1518

1619
- com.projectname.employee
1720
- com.projectname.leave
@@ -28,3 +31,16 @@ Subsequent components of the package name vary according to an organization's ow
2831
- com.projectname.factories
2932
- com.projectname.utils
3033
- 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+

docs/java/variables.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,28 @@ title: Variables
44
sidebar_label: Variables
55
---
66

7-
#### The following convention should be followed for variable naming:
7+
#### The following convention should be followed for variable naming
8+
9+
* Variable names should be **noun** or **adjectives** and should be **camelCase**. e.g age, balance, employeeReport etc
10+
11+
* Variable names should not start with underscore _ or dollar sign $ characters, even though both are allowed.
12+
13+
* Variable names should be short yet meaningful. The choice of a variable name should be mnemonic, self descriptive and semantical
14+
designed to indicate its intention.
15+
16+
* One-character variable names should be avoided like i, j, k, m etc
17+
18+
* Variable name should be plural if that is a collections. for e.g **employees**, **leaves** represents a list.
19+
20+
* Variables names should be declared as per their types
21+
* Map/KeyValue pair should be declared as *keyToValue* and *valueByKey*. For e.g **ageByName** or **nameToAge**.
22+
* Set can be prefixed as *unique* before variable names. For e.g **uniqueNames**
23+
24+
* Instance variable should be camelCase of their class names.
25+
* employeeService is an instance of EmployeeService.
26+
* reportDao is an instance of ReportDao.
27+
28+
## Constants
29+
30+
* Constants names holds same conventions as variable except it should be **UPPER_CASE** separated by **(_)** underscore.
31+
* **AGE_BY_NAME**, **EMPLOYEE_REPORT**

sidebars.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@ module.exports =
2626
"label": "Naming Convention",
2727
"items": [
2828
"java/packages",
29-
"java/files",
3029
"java/classes",
3130
"java/interfaces",
3231
"java/variables",
3332
"java/functions"
34-
3533
]
3634
}
3735
],

0 commit comments

Comments
 (0)