본문으로 건너뛰기
Skillpedia
일반 코딩280k · #191

java-coding-standards

하는 일

이 도구는 Java 코드가 모범 사례와 관례를 따르도록 돕습니다. 특히 Spring Boot나 Quarkus 프레임워크를 사용할 때 변수 이름, 데이터 저장 방식, 오류 처리 방식 등을 점검합니다.

사용하는 경우

  • ✓Spring Boot나 Quarkus 프로젝트를 위한 Java 코드를 작성할 때.
  • ✓코드를 읽고 관리하기 쉽게 만들고 싶을 때.
  • ✓다른 사람의 코드를 검토하면서 규칙을 따르는지 확인할 때.

스킬 링크

https://github.com/affaan-m/ECC/blob/main/pi/core/skills/java-coding-standards/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/affaan-m/ECC/blob/main/pi/core/skills/java-coding-standards/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“이 Spring Boot용 Java 코드가 이름 짓기와 불변성 관례를 따르는지 확인해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

이 도구는 코드를 분석하고, Spring Boot와 Quarkus 프레임워크를 위한 미리 정해진 규칙과 비교합니다. 맞지 않는 부분이 있으면 올바른 방법을 제안합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Java Coding Standards

Standards for readable, maintainable Java (17+) code in Spring Boot and Quarkus services.

When to Use

  • Writing or reviewing Java code in Spring Boot or Quarkus projects
  • Enforcing naming, immutability, or exception handling conventions
  • Working with records, sealed classes, or pattern matching (Java 17+)
  • Reviewing use of Optional, streams, or generics
  • Structuring packages and project layout
  • [QUARKUS]: Working with CDI scopes, Panache entities, or reactive pipelines

How It Works

Framework Detection

Before applying standards, determine the framework from the build file:

  • Build file contains quarkus → apply [QUARKUS] conventions
  • Build file contains spring-boot → apply [SPRING] conventions
  • Neither detected → apply shared conventions only

Core Principles

  • Prefer clarity over cleverness
  • Immutable by default; minimize shared mutable state
  • Fail fast with meaningful exceptions
  • Consistent naming and package structure
  • [QUARKUS]: Favor build-time over runtime processing; avoid runtime reflection where possible

Examples

The sections below show concrete Spring Boot, Quarkus, and shared Java examples for naming, immutability, dependency injection, reactive code, exceptions, project layout, logging, configuration, and tests.

Naming

// 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;

// PASS: [QUARKUS] JAX-RS resources named as *Resource, not *Controller
public class MarketResource {}

// PASS: [SPRING] REST controllers named as *Controller
public class MarketController {}

Immutability

// 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
}

// PASS: [QUARKUS] Panache active-record entities use public fields (Quarkus convention)
@Entity
public class Market extends PanacheEntity {
  public String name;
  public MarketStatus status;
  // Panache generates accessors at build time; public fields are idiomatic here
}

// PASS: [QUARKUS] Panache MongoDB entities
@MongoEntity(collection = "markets")
public class Market extends PanacheMongoEntity {
  public String name;
  public MarketStatus status;
}

Optional Usage

// PASS: Return Optional from find* methods
// [SPRING]
Optional<Market> market = marketRepository.findBySlug(slug);

// [QUARKUS] Panache
Optional<Market> market = Market.find("slug", slug).firstResultOptional();

// PASS: Map/flatMap instead of get()
return market
    .map(MarketResponse::from)
    .orElseThrow(() -> new EntityNotFoundException("Market not found"));

Streams Best Practices

// 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

Dependency Injection

// PASS: [SPRING] Constructor injection (preferred over @Autowired on fields)
@Service
public class MarketService {
  private final MarketRepository marketRepository;

  public MarketService(MarketRepository marketRepository) {
    this.marketRepository = marketRepository;
  }
}

// PASS: [QUARKUS] Constructor injection
@ApplicationScoped
public class MarketService {
  private final MarketRepository marketRepository;

  @Inject
  public MarketService(MarketRepository marketRepository) {
    this.marketRepository = marketRepository;
  }
}

// PASS: [QUARKUS] Package-private field injection (acceptable in Quarkus — avoids proxy issues)
@ApplicationScoped
public class MarketService {
  @Inject
  MarketRepository marketRepository;
}

// FAIL: [SPRING] Field injection with @Autowired
@Autowired
private MarketRepository marketRepository; // use constructor injection

// FAIL: [QUARKUS] @Singleton when interception or lazy init is needed
@Singleton // non-proxyable — use @ApplicationScoped instead
public class MarketService {}

Reactive Patterns [QUARKUS]

// PASS: Return Uni/Multi from reactive endpoints
@GET
@Path("/{slug}")

…
자주 묻는 질문

‘이름 짓기 관례’란 무엇인가요?

변수, 함수, 클래스의 이름을 어떻게 짓는지에 대한 규칙입니다. 코드를 더 쉽게 이해하도록 돕습니다. 예를 들어 Java에서는 클래스 이름이 보통 대문자로 시작합니다.

‘불변성(immutability)’이란 무엇인가요?

한 번 만들어진 데이터는 바꿀 수 없다는 뜻입니다. 불변 데이터를 사용하면 코드가 더 안전하고 예측 가능해집니다.

왜 Spring Boot와 Quarkus를 구분하나요?

각 프레임워크에는 최적의 성능과 유지보수성을 위해 따라야 하는 고유한 규칙과 모범 사례가 있기 때문입니다.

상세 정보

작성자의 원본 설명

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. Use when writing or reviewing Java in a Spring Boot or Quarkus service.

repo: affaan-m/ECC

인기도

GitHub 스타
280k
순위
#191
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬