같은 프로젝트를 오랫동안 개발하다 보면 drawable이나 layout 같은 리소스명이 규칙 없이 생성되게 된다. 여러 사람이 개발하거나, 내 마음이 바뀌거나... 리소스 작명 규칙을 정해놓고 그 규칙을 따르다 보면 가독성이 높아진다.
Basic Principle
[what]_[where]_[description]_[size]
whatactivity, fragment ...wheremain, user, settings ...descriptiontitle, content, profile ...size24dp, small ... (optional)
Layout
[what]_[where].xml
- activity, fragment, view , item, layout
- 예시
activity_main.xml,layout_article.xml
Strings
[where]_[description]
- 공통적인 문자열은
[where]에all또는common을 사용 - 예시
article_title,common_purchase
Drawables
[where]_[description]_[size]
- 공통 이미지는
all,common을 사용 - 예시
noti_icon_24dp
Ids
[what]_[where]_[description]
- 예시
tablayout_main,imageview_menu_profile
Dimensions
[what]_[where]_[description]_[size]
- waht은 width, height, size, margin, padding같은 것들이 들어갈 수 있다.
- 예시
height_toolbar,size_profile
한계점
- 모든 화면이 다른 이름을 가져야함 (
MainActivity,MainFragment는 같은main을 사용하기 때문에 충돌이 일어날수 있음) - 리펙토링이 자동으로 되지는 않음