Kotlin ๊ณต์ ๋ฌธ์์ Coding Convention๊ณผ Android Kotlin Guides๋ฅผ ๋ฐ๋ฅธ๋ค. ์ฐจ์ด์ ์ด๋ ์ถ๊ฐ ์ฌํญ์ ์๋์ ๊ฐ๋ค.
- Column limit์ 120์ ์ฌ์ฉํ๋ค.
- Boolean์ ๋ถ์ ํ ๋๋ ! ๋์ not()์ ์ฌ์ฉํ๋ค.
- ํน๋ณํ ๋ช ์๋์ง ์์ ๋ถ๋ถ์ ๊ธฐ๋ณธ์ ์ผ๋ก Java์ convention์ ๋ฐ๋ฅด๋๋ก ํ๋ค.
Google Java Style Guide๋ฅผ ๋ฐ๋ฅธ๋ค. ์ด ์ธ์ ์ฐจ์ด์ ์ด๋ ์ถ๊ฐ ์ฌํญ์ ์๋์ ๊ฐ๋ค.
- Column limit์ 120์ ์ฌ์ฉํ๋ค.
- Block indentation์ +4 spaces๋ฅผ ์ฌ์ฉํ๋ค.
- Static import๋ ์ฌ์ฉํ์ง ์๋๋ค.
- ์์ค์ฝ๋ ์๋จ์ ์ ์๊ถ ๋ฐ ์ ์๋ฅผ ํ์ํ๋ ์ฃผ์์ ๋จ๊ธฐ์ง ์๋๋ค.
-
layout
- activty, fragment ๋ฑ ๋ด๊ณ ์๋ ๋ด์ฉ์ ์ต์๋จ ๊ฐ๋ ์ prefix๋ก ํ๋ค.
- ๊ทธ ์ดํ๋ ์์ ๊ฐ๋ ์์ ํ์ ๊ฐ๋ ์ ์์ฐจ์ ์ผ๋ก ์ฌ์ฉํ๋ค.
- ์) activty_tutorial, fragment_shelf, shelf_toolbar
-
drawable
- ๊ธฐ๋ณธ์ ์ผ๋ก ์์ ๊ฐ๋ ์์ ํ์ ๊ฐ๋ ์ ์์ฐจ์ ์ผ๋ก ํ๊ธฐํ๋ค. ย - ํน์ ์์, ํ์ ๊ฐ๋ ์ ์ํ์ง ์๊ฑฐ๋, ์ฌ๋ฌ ์ฝ๋์ ๊ณตํต์ผ๋ก ์ฌ์ฉํ ๊ฒฝ์ฐ์๋ ํ๊ธฐํ์ง ์๋๋ค.
- ์) reader_typo_setting_column_width.xml, simple_noti_icon_error.png
- ์์ด์ฝ(icon), ๋ฒํผ(btn), ๋ฐฐ๊ฒฝ(bg), ์ ๋ ํฐ(sel)๋ฑ ๋ฆฌ์์ค์ ์ข ๋ฅ๋ฅผ ์, ํ์ ๊ฐ๋ ๋ค์์ ํจ๊ป ํ๊ธฐํ๋ค. ์, ํ์ ๊ฐ๋ ๊ณผ ๋ฆฌ์์ค์ ์ข ๋ฅ๋ฅผ ํ๊ธฐ ํ ๋ค ๊ธฐ๋ฅ๊ณผ ๋ชจ์์ ์ด์ธ๋ฆฌ๋ ์ด๋ฆ์ ์์ ๋กญ๊ฒ ์ถ๊ฐํ๋ค.
- ์) reader_tts_icon_pre.png / main_purchased_btn_book_read.png ย - ๋ฆฌ์์ค ์์, ํ์๊ฐ๋ ์ ์์ด ๋ช ์นญ์ ์๋๋ก์ด๋์ ํ์ฌ ๊ฐ๋ฐ๋ ์ํ๋ฅผ ์ฐธ๊ณ ํ์ฌ ํ๊ธฐํ๋ค.
- ์) ๋ด ์์ฌ(library), ๊ฐ๋ณ ์ฑ ์ฅ(shelf), ๊ตฌ๋งค๋ชฉ๋ก(purchased), ์์ (store), ์ค์ (settings),
- ์ฑ ์ฅ ๋ชฉ๋ก(shelf_list), ์ต๊ทผ ์ฝ์ ์ฑ (recent_book), ๋ ์๋ ธํธ(reading_note), ๋ณด๊ธฐ ์ค์ (typo_setting), ๋ทฐ์ด ์ค์ (reader_setting)
- ํ ๋ง์ ๋ฐ๋ผ ๋ฆฌ์์ค๋ฅผ ๊ตฌ๋ถํด์ผํ๋ ๊ฒฝ์ฐ, ๋คํฌ ํ ๋ง์ฉ ๋ฆฌ์์ค์ ๋งจ ๋ค์ _d๋ฅผ ๋ถ์ธ๋ค.
- ์) main_shelf_icon_uncheck_d.xml
-
id
- ๊ฐ๋จํ ์๋ฏธ๋ฅผ ์ด๋ฆ์ผ๋ก ์ด๋ค.
- ImageButton, Button, CheckBox, RadioButton๊ณผ ๊ฐ์ด Button ์ข ๋ฅ์ด๊ฑฐ๋ Button์ Subclass์ธ ๊ฒฝ์ฐ button์ postfix๋ก ํ๋ค.
- ProgressBar, SeekBar์ ๊ฒฝ์ฐ bar๋ฅผ postfix๋ก ํ๋ค.
- ViewGroup์ ๊ฒฝ์ฐ container๋ฅผ postfix๋ก ํ๋ค.
- ์)
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/toolbar_container" android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:id="@+id/cover" layout_width="wrap_content" layout_height="wrap_content" /> <Button android:id="@+id/download_button" layout_width="wrap_content" layout_height="wrap_content" /> </LinearLayout>
-
View variable naming
- ์์ id์ ๋์ผํ ํํ๋ก ์ฌ์ฉํ๋ camel case๋ฅผ ์ฌ์ฉํ๋ค.
- ๋ง์ฝ TextView๋ ImageView๋ฅผ ๋ฒํผ ๊ฐ์ ์ฉ๋๋ก ์ฌ์ฉํ๋ค๋ฉด Button์ postfix๋ก ์ฌ์ฉํ๋ค.
- ์)
TextView bookTitleView = (TextView) findViewById(R.id.book_title); ImageView coverView = (ImageView) findViewById(R.id.cover); Button downloadButton = (Button) findViewById(R.id.download_button); ImageButton deleteButton = (ImageButton) findViewById(R.id.delete_button); TextView confirmButton = (TextView) findViewById(R.id.confirm_button); ProgressBar downloadBar = (ProgressBar) findViewById(R.id.download_bar); SeekBar pageBar = (SeekBar) findViewById(R.id.page_bar); CheckBox syncButton = (CheckBox) findViewById(R.id.sync_button); RadioButton koreanDicButton = (RadioButton) findViewById(R.id.korean_dic_button);
- ๋์์ธ ๊ฐ์ด๋ ์์ Medium์ผ๋ก ํํ๋ ํฐํธ์ผ ๊ฒฝ์ฐ
bold
์์ฑ์ ์ ์ฉํ๋ค. - ํ ์คํธ์ ๊ด๋ จ๋ ๊ธฐํ ์ค์ ์ RIDI Design System ์ ๋ฐ๋ฅธ๋ค.