Java
Casing Rules
| Element | Convention | Example |
|---|---|---|
| Classes | PascalCase | OrderService, UserRepository |
| Interfaces | PascalCase | PaymentProcessor, UserRepository |
| Enums | PascalCase | PaymentMethod, OrderStatus |
| Enum constants | SCREAMING_SNAKE_CASE | CREDIT_CARD, IN_PROGRESS |
| Methods | camelCase | getUserById, processPayment |
| Variables | camelCase | userCount, isActive |
Constants (static final) | SCREAMING_SNAKE_CASE | MAX_RETRY_COUNT, DEFAULT_TIMEOUT_MS |
| Packages | lowercase.dot.separated | com.acmeco.retail.orders |
File Naming
One public class per file. The file name must match the class name exactly.
# Good:
OrderService.java
UserRepository.java
PaymentProcessor.java
# Test files mirror the source:
OrderServiceTest.java
UserRepositoryIT.java # integration test suffix
OrderWorkflowE2ETest.java
Package Naming
Packages follow a reverse-domain hierarchy:
com.{company}.{org}.{solution}.{layer}
com.acmeco.retail.orders.service
com.acmeco.retail.orders.repository
com.acmeco.retail.orders.model
Keep packages lowercase with no underscores or hyphens. Each segment should be a single meaningful word.