일반적으로 Google Style Guide는 snake_case 변수명과 CamelCase 함수명을 사용하며, LLVM Coding Standards는 camelCase를 사용합니다.
변수명 == snake
함수 == camel
클래스 == pascal
파일명 == pascal 네임스페이스 == snake
<aside> 🐫 함수명, 변수명은 카멜케이스로 작성합니다.
</aside>
<aside> 🐍 ID 및 attr는 스네이크케이스로 작성합니다.
// string.xml [페이지이름_attr명]
<string name="profile">마이페이지</string>
<string name="profile_user_name">홍길동님</string>
<string name="profile_user_info">내 정보</string>
<string name="profile_user_info_text1">학교 정보 수정하기</string>
// fragment_profile.xml
android:id="@+id/profile_guideline1"
android:id="@+id/profile_card"
android:id="@+id/profile_card_guideline1"
</aside>
<aside> ☝ 가독성을 위해 한 줄에 하나의 문장만 작성합니다.
</aside>
<aside> <img src="https://cdn-icons-png.flaticon.com/512/3602/3602241.png" alt="https://cdn-icons-png.flaticon.com/512/3602/3602241.png" width="40px" /> 주석은 설명하려는 구문에 맞춰 들여쓰기 합니다.
// Good
function someFunction() {
...
// statement에 관한 주석
statements
}
</aside>
<aside> <img src="https://cdn-icons-png.flaticon.com/512/3978/3978575.png" alt="https://cdn-icons-png.flaticon.com/512/3978/3978575.png" width="40px" /> 연산자 사이에는 공백을 추가하여 가독성을 높입니다.
a+b+c+d // bad
a + b + c + d // good
</aside>
<aside> ☝ 콤마 다음에 값이 올 경우 공백을 추가하여 가독성을 높입니다.
var arr = [1,2,3,4]; //bad
var arr = [1, 2, 3, 4]; //good
</aside>
<aside> 🔠 생성자 함수명의 맨 앞글자는 대문자로 합니다.
function Person(){}
</aside>