Java – Naming Conventions
| Element | Convention | Example |
|---|---|---|
| Class / Interface | PascalCase | UserService, PaymentProcessor |
| Method | camelCase | getUserById(), processPayment() |
| Variable | camelCase | userName, totalAmount |
| Constant | UPPER_SNAKE_CASE | MAX_RETRY_COUNT |
| Package | lowercase.dotted | com.cygnus.service.user |
| Enum | PascalCase (values: UPPER) | PaymentStatus.PENDING |
Rules
- Names must be descriptive — avoid
x,tmp,data - Boolean variables should read as questions:
isActive,hasPermission - Avoid abbreviations unless universally known (
url,id,dto)