Skip to content

Commit 2da5cd2

Browse files
glaudeeeclaude
andcommitted
Sync the vendored java skill: underscore prefix for hierarchy fields
The naming convention now reserves the underscore prefix for fields used inside the class hierarchy (~/.claude b75c844). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent b5dfaec commit 2da5cd2

2 files changed

Lines changed: 25 additions & 17 deletions

File tree

‎.claude/skills/java/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: java
33
description: Umfassende Java-Entwicklungsrichtlinien für Backend-Projekte. Enthält Konventionen, Integrationen (PostgreSQL, Javalin, Jackson, Log4j2), Patterns (Clean Architecture, Repository) und Build-Konfiguration (Maven). Triggers auf Java-Code, REST APIs, Datenbank, jOOQ, Flyway, DTOs, Records, Logging, Properties, Identifiers, Security.
44
# GENERIERT aus personal/skills-ref/java/ — nicht hier editieren; Aenderungen gehoeren nach ~/.claude/skills-ref/java/.
55
source: personal-provider-ref
6-
ref-hash: sha256:c9b1fe65dbfd6413221ddb5a5bea9c6c7dea36cd7b40623b0c2c4fc1efad50d0
6+
ref-hash: sha256:2d884146fda34eff4a06b1fa7ef20c10ca6b9b95759d900197179f6e6e27dc6f
77
---
88

99
# Java Development Guide

‎.claude/skills/java/rules/convention-naming.md‎

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,25 @@ public Optional<Product> findProductById(final UUID id) {
4949
### Variablen
5050

5151
- **camelCase** für lokale Variablen
52-
- **_underscorePrefix** für private Felder
52+
- **_underscorePrefix** nur für `private`/`protected` Felder, die ausschliesslich aus der eigenen Klassenhierarchie gelesen werden — als `_feld`, nie als `objekt._feld`
53+
- Ein Feld, das direkt über ein Objekt gelesen wird (`objekt.feld`), ist `public` und trägt keinen Underscore
54+
- Auch der Zugriff über eine andere Instanz derselben Klasse (z.B. `other.id` in `equals`) zählt als Zugriff über ein Objekt
5355
- `final` bevorzugen
5456

5557
```java
56-
public class Example {
57-
private final ProductRepository _productRepository;
58+
public class Order {
59+
public final OrderId id; // wird von aussen gelesen: order.id
60+
protected final Money _total; // nur Order und Unterklassen: _total
61+
private final List<Line> _lines; // nur Order selbst: _lines
5862

59-
public void process() {
60-
final var products = _productRepository.findAll();
63+
public boolean equals(final Object o) {
64+
return o instanceof final Order other && id.equals(other.id); // other._id waere falsch
6165
}
6266
}
67+
68+
// anderswo
69+
final var orderId = order.id; // richtig
70+
final var total = order._total; // falsch: Underscore-Feld ueber ein Objekt
6371
```
6472

6573
### Konstanten
@@ -116,20 +124,20 @@ public enum CrmOrganisationType {
116124
Supplier(OrganisationType.supplier, "crm.organisation.type.supplier"),
117125
ServiceProvider(OrganisationType.service_provider, "crm.organisation.type.service_provider");
118126

119-
private final OrganisationType jooqType;
120-
private final String translationKey;
127+
private final OrganisationType _jooqType;
128+
private final String _translationKey;
121129

122-
CrmOrganisationType(OrganisationType jooqType, String translationKey) {
123-
this.jooqType = jooqType;
124-
this.translationKey = translationKey;
130+
CrmOrganisationType(final OrganisationType jooqType, final String translationKey) {
131+
_jooqType = jooqType;
132+
_translationKey = translationKey;
125133
}
126134

127-
public OrganisationType jooq() { return jooqType; }
128-
public String translationKey() { return translationKey; }
135+
public OrganisationType jooq() { return _jooqType; }
136+
public String translationKey() { return _translationKey; }
129137

130-
public static CrmOrganisationType fromDatabase(OrganisationType db) {
131-
for (var value : values()) {
132-
if (value.jooqType == db) return value;
138+
public static CrmOrganisationType fromDatabase(final OrganisationType db) {
139+
for (final var value : values()) {
140+
if (value.jooq() == db) return value;
133141
}
134142
throw new IllegalArgumentException("Unknown: " + db);
135143
}
@@ -157,7 +165,7 @@ net.example.project.product.usecase
157165
- [ ] Klassen/Records: PascalCase mit Suffix (*Dto, *Repository, etc.)
158166
- [ ] Interfaces: PascalCase ohne I-Prefix
159167
- [ ] Methoden: camelCase mit Verb-Prefix
160-
- [ ] Private Felder: _underscorePrefix
168+
- [ ] Underscore nur bei private/protected Feldern, die ausschliesslich aus der eigenen Klassenhierarchie gelesen werden; Zugriff ueber ein Objekt nur auf public-Felder ohne Underscore
161169
- [ ] Konstanten: UPPER_SNAKE_CASE
162170
- [ ] Enums: PascalCase (Klasse und Werte)
163171
- [ ] Packages: lowercase

0 commit comments

Comments
 (0)