네이밍 컨벤션
전체 규칙 요약
| 대상 | 규칙 | 예시 |
|---|---|---|
| 클래스 | PascalCase | UserService, BoardController |
| 메서드/변수 | camelCase | getUserById, isActive |
| 상수 | UPPER_SNAKE_CASE | MAX_RETRY_COUNT |
| DB 컬럼/테이블 | snake_case | user_id, created_at |
| 패키지 | 소문자 | com.scraping.agent.domain |
| REST URL | 소문자 케밥케이스 | /api/v1/user-posts |
| VO (요청) | 목적 + Req 접미사 | UserCreateReq, BoardSearchReq |
| VO (응답) | 목적 + Res 접미사 | UserDetailRes, BoardListRes |
| 예외 클래스 | 의미 있는 이름 + Exception | UserNotFoundException |
메서드 네이밍 동사 규칙
| 동작 | 접두사 | 예시 |
|---|---|---|
| 등록/생성 | reg | regUser, regPost |
| 수정 | upt | uptUser, uptPost |
| 삭제 | del | delUser, delPost |
| 단건 조회 | get | getUser, getPost |
| 목록 조회 | get + List/Page | getUserList, getPostPage |
패키지 구조
com.scraping.agent
├── domain/
│ └── {도메인}/
│ ├── controller/
│ ├── service/
│ ├── repository/
│ ├── vo/ # Req / Res VO
│ └── {Domain}.java # Entity
└── global/
├── batch/
├── common/ # ApiResponse, BaseEntity
├── config/
├── constant/
├── exception/
├── health/
├── slack/
└── util/
상수 관리
// 패키지: com.scraping.agent.global.constant
// 파일: {도메인명}Constant.java
public class PagingConstant {
private PagingConstant() {} // 인스턴스 생성 방지
public static final int DEFAULT_SIZE = 10;
public static final int MAX_SIZE = 100;
}
public class CategoryConstant {
private CategoryConstant() {}
public static final String AI = "AI";
public static final String BACKEND = "BACKEND";
public static final String DEVOPS = "DEVOPS";
public static final String JOB = "JOB";
}
하드코딩 금지 대상:
- 상태값 (
"A","I","D") - 메시지 문자열
- 숫자 매직 넘버
- API URL
- 파일 경로
Lombok 컨벤션
// Entity — protected 기본 생성자
@Entity
@Getter
@SuperBuilder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Post extends BaseEntity {
// ...
}
// 요청 VO (Req)
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class PostCreateReq {
private String title;
private String content;
}
// 응답 VO (Res) — Builder 패턴
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PostDetailRes {
private Long id;
private String title;
}
규칙:
@AllArgsConstructor단독 사용 금지- Entity:
@NoArgsConstructor(access = AccessLevel.PROTECTED) @Data사용 금지 (equals/hashCode 오버라이드 위험)
DB 컬럼 네이밍
-- 테이블명: 소문자 snake_case, 복수형
CREATE TABLE news_items (
id BIGINT NOT NULL AUTO_INCREMENT,
title VARCHAR(500) NOT NULL,
url VARCHAR(2000) NOT NULL,
category VARCHAR(50) NOT NULL,
is_active TINYINT(1) NOT NULL DEFAULT 1,
frst_regist_dt DATETIME,
last_updt_dt DATETIME,
deleted_at DATETIME,
PRIMARY KEY (id)
);
| 패턴 | 규칙 |
|---|---|
| PK | id (BIGINT AUTO_INCREMENT) |
| FK | {참조테이블단수}_id → user_id, post_id |
| Boolean | is_ 접두사 → is_active |
| 인덱스명 | idx_{테이블명}_{컬럼명} |
| 감사 컬럼 | frst_regist_dt, last_updt_dt |
Thymeleaf 파일 네이밍
templates/
├── {도메인}/
│ ├── list.html # 목록 페이지
│ ├── detail.html # 상세 페이지
│ └── form.html # 등록/수정 폼
├── layout/
│ ├── default.html # 일반 레이아웃
│ ├── blank.html # 어드민 레이아웃
│ └── guide.html # 가이드 레이아웃
└── fragments/
└── {컴포넌트명}.html
CSS 클래스: BEM-like ({블록}-{요소}, {블록}--{변형})
.news-card {}
.news-card-title {}
.news-card--featured {}