Professional Documents
Culture Documents
ISP Java Coding Practices v0.1
ISP Java Coding Practices v0.1
2020
General practices
1. Commit messages should be in english.
a. E.g: git commit -m “Added implementation for ex1”
2. Class / variables names should be in english
a. E.g: UserService, age, nrOfEmployees
3. Format the code. Use the shortcut:
a. Windows: CTRL + ALT + L
b. Ubuntu: CTRL + ALT + WINDOWS + L
c. Mac: OPTION + COMMAND + L
4. Project code location vs Tests code location
a. Project code is written under src/main/java package
b. Tests code is written under src/test/java package
Coding style
Formatting
● Format the code using IDE shortcuts.
1
ISP Java Coding Practices Version 0.1 03.2020
Curly braces
Generally, is a good practice to use curly braces even with a single instruction.
TODOs
TODO’s that are fixed should be removed from code.
Types / Variables
CamelCase for types, camelCase for variables, SNAKE_CASE for constants
2
ISP Java Coding Practices Version 0.1 03.2020
Modifiers orders
The order of modifiers should be:
For fields\methods:
@Annotation public protected private abstract static final synchronized native strictfp
Access modifiers
Use private access modifier for class variables. States should be changed using setter
methods. State should be retrieved using getter methods.
Use protected access modifier for class variables only when the class is extended by
different class.
3
ISP Java Coding Practices Version 0.1 03.2020
4
ISP Java Coding Practices Version 0.1 03.2020
5
ISP Java Coding Practices Version 0.1 03.2020
Documentation
Documenting a class
A class doc usually has at least one sentence summary. If the class has a more
complicated behavior, then a more detailed explanation may be needed.
Documenting a method
The method doc should explain what the method does. We shouldn't include
documentation that doesn't tell nothing that the method declaration didn't.
6
ISP Java Coding Practices Version 0.1 03.2020