거창하지 않지만 중요한 개발 잡담

Nameless - 좋은 이름을 짓는 방법

NAEU 2025. 12. 6. 10:23

언어별 예약어를 사용하지 말것 ex) int, float, for etc
컴파일러 예약어도 사용하지 말것 ex) __언더바2개, _Muck언더바후대문자
모두가 알고있는 약어만 사용할 것
같은 내용을 반복하지 말것

void saveEmployee(const Employee employee);
보다는
void save(const Employee employee);

프로퍼티도 이름의 일부로서 사용
bool bIsNotPlayer 처럼 논리형에 부정문 사용하지 않기 => bIsPlayer
귀찮더라도 임시변수에 이름 지정 ex) for문의 i, iterator의 it, templete의 T
어떻게 구현했지는지 생각하지 않기

pair<Player, int> GetPlayerLevelPairInt(const std::string name);
보다는
pair<Player, int> GetPlayerLevel(const std::string name);

위의 상황에서 "같은 내용 반복하지 말라"는 의미로 GetLevel로 함수명을 지정하면 안되냐 생각될 수도 있지만 리턴값이 아닌 프로퍼티에 한정하기 때문에 다름

pair<Player, int> GetLevel(const Player player);

라면 괜찮음