Skip to content

Commit c857e89

Browse files
committed
update java.md to specify consistent class name suffixes for architectural roles and discourage custom suffixes for improved clarity and consistency
1 parent 10539da commit c857e89

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

  • claude-project-base/conventions

claude-project-base/conventions/java.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ Formatting rules (indentation, charset, line endings) are defined in `.editorcon
2424
- Do not use `var`
2525
- Follow standard Java naming: `PascalCase` for classes, `camelCase` for methods/fields, `UPPER_SNAKE_CASE` for
2626
constants.
27+
- **IMPORTANT**: Use consistent class name suffixes to express architectural roles:
28+
- `Service` — Business-logic classes (e.g., `UserService`, `PaymentService`).
29+
- `Repository` — Data access layer classes (e.g., `UserRepository`, `OrderRepository`).
30+
- `Entity` — JPA entities / persisted domain objects (e.g., `UserEntity`, `OrderEntity`).
31+
- `DTO` — Data Transfer Objects for the API layer and between internal layers (e.g., `UserDTO`, `OrderDTO`). This is the default suffix for all objects that carry data across layer boundaries, including REST request and response bodies.
32+
- `Request` / `Response` — Use only when a generic DTO does not fit, for example when request and response structures differ significantly or when separate naming improves clarity. Prefer `DTO` as the default.
33+
- `Controller` — REST controllers / route handlers (e.g., `UserController`).
34+
- `Registry` — Central lookup or management of objects (e.g., `ServiceRegistry`, `EventRegistry`).
35+
- `Config` or `Configuration` — Configuration classes (e.g., `SecurityConfig`, `DatabaseConfiguration`).
36+
- Do not invent custom suffixes for these roles — use the ones listed above for consistency across projects.
2737
- **IMPORTANT**: Do not use Lombok. Use modern Java features (records, pattern matching) instead.
2838
- Always override `equals`, `hashCode`, and `toString` together for non-record classes. Use `Objects.equals()` and
2939
`Objects.hash()` as helpers.

0 commit comments

Comments
 (0)