Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Java coding standards for Spring Boot and Quarkus services: naming, immutability, Optional usage, streams, exceptions, generics, CDI, reactive patterns, and project layout. Automatically applies framework-specific conventions.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 37% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 1% | 0% |
| case-16 | ✗→✓ | ▲ Improved | 37% | 0% |
| case-18 | ✗→✓ | ▲ Improved | 29% | 0% |
| case-10 | ✓→✓ | = Same ✓ | -3% | 0% |
适用于 Spring Boot 服务中可读、可维护的 Java (17+) 代码的规范。
java// PASS: Classes/Records: PascalCase public class MarketService {} public record Money(BigDecimal amount, Currency currency) {} // PASS: Methods/fields: camelCase private final MarketRepository marketRepository; public Market findBySlug(String slug) {} // PASS: Constants: UPPER_SNAKE_CASE private static final int MAX_PAGE_SIZE = 100;
java// PASS: Favor records and final fields public record MarketDto(Long id, String name, MarketStatus status) {} public class Market { private final Long id; private final String name; // getters only, no setters }
java// PASS: Return Optional from find* methods Optional<Market> market = marketRepository.findBySlug(slug); // PASS: Map/flatMap instead of get() return market .map(MarketResponse::from) .orElseThrow(() -> new EntityNotFoundException("Market not found"));
java// PASS: Use streams for transformations, keep pipelines short List<String> names = markets.stream() .map(Market::name) .filter(Objects::nonNull) .toList(); // FAIL: Avoid complex nested streams; prefer loops for clarity
MarketNotFoundException)catch (Exception ex),除非在中心位置重新抛出/记录javathrow new MarketNotFoundException(slug);
javapublic <T extends Identifiable> Map<Long, T> indexById(Collection<T> items) { ... }
src/main/java/com/example/app/
config/
controller/
service/
repository/
domain/
dto/
util/
src/main/resources/
application.yml
src/test/java/... (mirrors main)javaprivate static final Logger log = LoggerFactory.getLogger(MarketService.class); log.info("fetch_market slug={}", slug); log.error("failed_fetch_market slug={}", slug, ex);
@Nullable;否则使用 @NonNull@NotNull, @NotBlank)记住:保持代码意图明确、类型安全且可观察。除非证明有必要,否则优先考虑可维护性而非微优化。
Other measured skills in the registry, with their headline benchmark lift.