본문 바로가기
카테고리 없음

변수명 🍪🍫☘️

by s2jinny 2026. 2. 4.
반응형

타입별 기본 규칙

 

1. bool 

🅾️-> isSelected, hasDiscount, canSubmit 

❌ -> discountYn, flag, check

 

읽으면 yes/no로 대답 가능해야 함

 

2. 숫자 (단위)

🅾️-> totalPrice, discountAmount, maxQuantity 

❌ -> count, num, price, rate 

 

3. List ( 복수형 + 무엇의 리스트인지 ) 

🅾️-> products, availableCounpons, selectedItems

❌ -> list items // 너무 포괄적

 

4. 어디에 쓰이는 지가 이름에 들어나야 함 .

🅾️->final orderStatus;, final loadingStatus;

❌ -> final status;  

 

5. 변수명 짓는 쉬운 공식 

[대상] + [상태/의미] : orderStatus userLoginState couponDiscountAmount

 

6. if 문에서 변수명 

🅾️-> 조건식을 변수명으로 설명

final hasDiscount = discountAmount > 0; 
	if (hasDiscount) {

 

❌ ->

if (discount > 0) {

 

7. 부정문 쓰지 않기 

🅾️-> isSelected isAvailable

❌ -> isNotSelected isNotAvailable

 

8. 타입이 말해주는 정보 중복하지 않기 

🅾️-> final List products;  // 변수명에 list 안 쓰기

❌ -> final List productList;