Coding Standard - Rokeya-Siddiqua/CSE327-Online-House-Rental-Management-System GitHub Wiki
CODING STANDARD pdf drive link
Indentation:
Four spaces should be used as the unit of indentation. The indentation pattern should be consistently followed throughout.
Example:
Indentation used in a loop construct. Four spaces are used for indentation.
for ( int i = 0 ; i < numberOfEmployees ; ++i )
{
totalWages += employee [ i ] . wages ;
}
Naming Conventions:
1. Package Names:
- Package Names Typed in lowercase.
Example:
Acceptable:
-
javax.sql.
-
java.lang.
-
com.newpackage.
Not Acceptable:
-
Com.newPackage.
-
Com.new_Package.
2. Class Names:
- Typed in Camel Case.
Example:
Acceptable:
-
homePage.
-
register.
-
landLordPage.
Not Acceptable:
-
demopage.
-
Log_Out.
3. Interface Names:
- Interface Names typed in Upper Camel Case.
Example:
Acceptable:
-
addNumbers().
-
Person.
Not Acceptable:
- person.
4. Methods Names:
- Methods names typed in a lower Camel Case.
Example:
Acceptable:
-
isNull().
-
locationListener().
-
googleMap.
Not Acceptable:
-
demopage.
-
Log_Out.
5. Constants:
-
Constants are types in uppercase.
-
Constants separated by an underscore.
Example:
Acceptable:
-
MAX_VALUE.
-
MIN_VALUE.
Not Acceptable:
-
Size_number.
-
Log_Out .
6. Variables :
- Variables are typed in lower Camel Case.
Example:
Acceptable:
-
phoneNumber.
-
birthdate.
-
email.
Not Acceptable:
-
PassWord.
-
Logout.
Comments:
Block Comments:
Block comments are used to provide descriptions of files, methods, data structures and algorithms. It should be used at the beginning of each file.
Documentation comments delimited by /……*/.
For Example,
/*
- Here is a block comment.
*/
Use of Braces:
Braces should be used to delimit the bodies of conditional statements, control constructs, and blocks of scope.
Acceptable:
for ( int j = 0 ; j < maxNum ; ++j )
{
System.out.printf( “Show the Max number’);
}
Not Acceptable:
for ( int j= 0; j < maxNum ; ++j ){
System.out.printf( “Show the Max number’);
}
Braces shall be used even when there is only one statement in the control block.
Example:
Bad:
if (j == 0)
printf (“j is zero.\n”);
Better:
if (j == 0)
{
printf (“j is zero.\n”);
}
Member Order:
Member order should be first public members after then protected members and lastly private member.
For Example,
public static properties
public properties
protected properties
private properties
public constructors
protected constructors
private constructors
static methods
non-static method