← ClaudeAtlas

java-clean-nameslisted

Enforces naming in Java 21+ — descriptive names, names matched to scope, no Hungarian notation or I-prefixed interfaces, no meaningless suffixes like Manager or Helper, and names that reveal side effects. Use when naming or renaming variables, fields, methods, classes, records, interfaces, or packages in Java, and when the user asks "rename this", "better name", "what should I call this", or the code shows cryptic identifiers, `Impl` suffixes, or getters that mutate.
CasLubbers/code-design-skills · ★ 1 · Code & Development · score 62
Install: claude install-skill CasLubbers/code-design-skills
# Clean names in Java ## Reveal intent If a name needs a comment to explain it, the name is wrong. ```java // Bad int d; List<int[]> theList; // Good int elapsedDays; List<Cell> flaggedCells; ``` ```java // Bad — what does this return? public List<User> get(int x) { ... } // Good public List<User> findUsersOlderThan(int minimumAge) { ... } ``` ## Name at the right level of abstraction The name describes what the caller gets, not how it is stored. ```java // Bad — leaks the implementation Map<String, List<Order>> getOrderHashMapByCustomerId() // Good Map<String, List<Order>> ordersByCustomer() ``` Changing a `HashMap` to a `TreeMap` should not require renaming anything. ## Length matches scope Short names are fine in short scopes and wrong at class or package level. ```java // Good — lifetime is one line orders.forEach(o -> total = total.add(o.amount())); // Good — visible everywhere, so it earns its length private static final Duration DEFAULT_CONNECTION_TIMEOUT = Duration.ofSeconds(30); // Bad — a field nobody can interpret private int max; ``` `var` shifts weight onto the name — with the type gone from the left, the right side must carry it. ```java var result = process(input); // bad — two mysteries var settledInvoices = process(input); // good ``` ## No encodings Modern tooling makes type prefixes noise. ```java // Bad String strName; List<User> lstUsers; private int m_count; interface IUserRepository {} class UserRepositoryImpl imple