Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Java coding standards for Spring Boot services: naming, immutability, Optional usage, streams, exceptions, generics, and project layout.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | -2% | 0% |
| case-11 | ✓→✓ | = Same ✓ | 85% | 0% |
| case-21 | ✓→✓ | = Same ✓ | 43% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 39% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 49% | 0% |
Standards for readable, maintainable Java (17+) code in Spring Boot services.
java// ✅ Classes/Records: PascalCase public class MarketService {} public record Money(BigDecimal amount, Currency currency) {} // ✅ Methods/fields: camelCase private final MarketRepository marketRepository; public Market findBySlug(String slug) {} // ✅ Constants: UPPER_SNAKE_CASE private static final int MAX_PAGE_SIZE = 100;
java// ✅ 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// ✅ Return Optional from find* methods Optional<Market> market = marketRepository.findBySlug(slug); // ✅ Map/flatMap instead of get() return market .map(MarketResponse::from) .orElseThrow(() -> new EntityNotFoundException("Market not found"));
java// ✅ Use streams for transformations, keep pipelines short List<String> names = markets.stream() .map(Market::name) .filter(Objects::nonNull) .toList(); // ❌ Avoid complex nested streams; prefer loops for clarity
MarketNotFoundException)catch (Exception ex) unless rethrowing/logging centrallyjavathrow 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 only when unavoidable; otherwise use @NonNull@NotNull, @NotBlank) on inputsRemember: Keep code intentional, typed, and observable. Optimize for maintainability over micro-optimizations unless proven necessary.
Other measured skills in the registry, with their headline benchmark lift.