본문 바로가기
코딩 · 개발원문 · prompts.chat

변수·함수·파일 이름과 코드 주석 원칙

변수, 함수, 파일 이름 짓기와 유용한 코드 주석 작성에 대한 의견이 분명한 선호 기준을 정리합니다.

원제 · Naming and Code Comments taste

추천 툴
코딩 에이전트형식 기준 추천

프롬프트 원문

# Naming and Code Comments taste of a senior engineer who reviews a lot of code
- Name things for what they mean in the domain (`invoiceDueDate`), not for their type (`dateString`). Confidence: 0.90
- Prefer full words over abbreviations; `customer` beats `cust`, except for universal ones like `id`, `url` and `i`. Confidence: 0.85
- Let name length grow with scope: a loop index can be `i`, a module-level export needs a descriptive name. Confidence: 0.85
- Name booleans as questions or states: `isActive`, `hasAccess`, `shouldRetry`. Confidence: 0.90
- Name functions with a verb that says what they do (`calculateTax`, `fetchUser`); keep `get` for cheap, side-effect-free reads. Confidence: 0.85
- Put units in names when the type doesn't carry them: `timeoutMs`, `sizeBytes`, `priceCents`. Confidence: 0.90
- Avoid vague names like `data`, `info`, `manager`, `helper` and `utils`; they hide what the code is for. Confidence: 0.80
- Use one word per concept across the codebase; don't mix `fetch`, `retrieve` and `load` for the same operation. Confidence: 0.85
- Follow the language's casing conventions exactly and let the linter enforce them. Confidence: 0.90
- Rename freely with IDE refactoring when a better name appears; a misleading name is a bug. Confidence: 0.80
- Write comments that explain why, not what; the code already says what. Confidence: 0.95
- Delete a comment that just restates the next line. Confidence: 0.85
- Replace a comment that explains a confusing block with a well-named function or variable when possible. Confidence: 0.80
- Document every public function, type and module with a doc comment covering purpose, parameters, errors and an example when useful. Confidence: 0.80
- Comment non-obvious constraints, workarounds and magic numbers, with a link to the issue or spec. Confidence: 0.90
- Write TODOs as `TODO(owner): what and why` with an issue link; a TODO without an owner is noise. Confidence: 0.75
- Never leave commented-out code in a commit; version control remembers it. Confidence: 0.95
- Update or delete comments in the same change that makes them stale. Confidence: 0.90
- Keep comments in plain English, short and in complete sentences. Confidence: 0.70
- Name tests after the behavior they check (`rejects expired tokens`), not the method they call. Confidence: 0.85
- Name files after the main thing they export, so search by name finds them. Confidence: 0.75
- Point out a confusing name in code review even when the logic is correct. Confidence: 0.80

출처 · prompts.chat 공개 프롬프트 모음 · 작성 Fatih Kadir Akın — CC0(저작권 포기)로 공개된 원문을 그대로 싣습니다. 한국어 제목 · 설명은 AI 번역이며, 실행 결과는 아직 없습니다.

같은 분야 프롬프트 코딩 · 개발

더 보기 ›