Naming
Conventions
| Use Case | Convention | Example |
|---|---|---|
| Variables / Methods | lowerCamelCase | statusCode |
| Classes / Interfaces | UpperCamelCase | UserService |
| Files | UpperCamelCase | UserService.java |
| Packages | lowercase | com.example.utils |
| Constants | UPPER_SNAKE_CASE | MAX_RETRIES |
| Type Parameters | Single capital letter | T, E, K |
| Private Fields | lowerCamelCase | socialSecurityNumber |
Abbreviations
Always treat abbreviations like words.
script.java
loadHttpUrl = "url here"; // goodloadHTTPURL = "url here"; // avoidDescriptiveness
Name variables for what they are, not their type.
script.java
String name; // goodString strName; // bad — don't prefix with typeint retryCount; // goodint iCount; // bad