Skip to content

Code Convention

sangyeop edited this page Jan 8, 2026 · 3 revisions

📌 코드 컨벤션

1️⃣ 네이밍 규칙

  • 변수명: snake_case
int player_count;
float max_speed;
  • 객체명(인스턴스): camelCase
PlayerController playerController;
  • 클래스명: PascalCase
class PlayerController;
class GameManager;
  • 파일명: snake_case
player_controller.cpp
game_manager.h

2️⃣ 함수 규칙

  • 함수 정의 시 중괄호는 개행 후 작성
void update_player()
{
    // ...
}

3️⃣ 반복문 (for / while)

  • 반복문용 지역 변수는 for문의 첫 번째 괄호 내부에서 선언
  • while보다 for문 사용을 우선
  • 후위 증가(i++)보다 전위 증가(++i) 사용
for (int i = 0; i < count; ++i)
{
    // ...
}

4️⃣ 조건문 (if)

  • 조건이 1개인 경우 삼항 연산자 사용 가능
int bonus = is_alive ? 10 : 0;
  • 조건이 1개인 경우 중괄호 생략 가능
if (is_valid)
    process();
  • 조건이 2개 이상이거나 가독성이 떨어질 경우 중괄호 필수
if (is_valid && is_ready)
{
    process();
}

Clone this wiki locally