Skip to content

๐Ÿ‘จโ€๐Ÿ’ป ์ฝ”๋“œ ์ปจ๋ฒค์…˜

์ตœ์ง€ํ™˜ edited this page Nov 21, 2022 · 12 revisions
๐Ÿ’ก ํŒ€ ๋‚ด ์ฝ”๋“œ ์ปจ๋ฒค์…˜

1. Kotlin

ํŒจํ‚ค์ง€

  • ํŒจํ‚ค์ง€๋ช…์€ ํ•ญ์ƒ ์†Œ๋ฌธ์ž

ํ•จ์ˆ˜๋ช…

  • ViewModel์„ observe() ํ•  ๋•Œ ๋ชจ์•„๋†“๋Š” ํ•จ์ˆ˜ ์ด๋ฆ„
fun setupXXX()
  • ์„œ๋ฒ„์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ๋ถˆ๋Ÿฌ์˜ฌ ๋•Œ ํ•จ์ˆ˜ (return ๊ฐ’ ์—†๋Š” ๊ฒฝ์šฐ)
fun fetchXXX()
  • ์„œ๋ฒ„์— ์ €์žฅํ•  ๋•Œ ํ•จ์ˆ˜
fun saveXXX()
  • return ๊ฐ’์ด ์žˆ๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ๋ถˆ๋Ÿฌ์˜ฌ ๋•Œ ํ•จ์ˆ˜
fun getXXX()
  • ๋ณต์ˆ˜ํ˜•์„ ๊ฐ€์ ธ์˜ฌ ๋• ๋’ค์— s ๋ถ™์ด๊ธฐ
fun getProducts()
  • BindingAdpater ํ•จ์ˆ˜๋Š” bindXXX ํ˜•ํƒœ๋กœ ์ •์˜
fun bindIsGone(view: View, isGone: Boolean)

๊ธฐํƒ€

  • Trailing Comma ์‚ฌ์šฉ
data class Moment(val a: Type1, val b: Type2,)

2. Resource

Layout

  • <WHAT>_<WHERE>

<WHAT>

Prefix ์„ค๋ช…
activity_ Activity์— ์“ฐ์ด๋Š” layout
fragment_ Fragment์— ์“ฐ์ด๋Š” layout
dialog_ Dialog์—์„œ ์“ฐ์ด๋Š” layout
view_ CustomView์—์„œ ์“ฐ์ด๋Š” layout
list_item_ RecyclerView, GridView, ListView ๋“ฑ์—์„œ ViewHolder์— ์“ฐ์ด๋Š” layout
layout_ ๋กœ ์žฌ์‚ฌ์šฉ๋˜๋Š” ๊ณตํ†ต์˜ layout

ID

  • <WHAT>_<DESCRIPTION>
  • View์˜ ๋Œ€๋ฌธ์ž๋ฅผ ์ถ•์•ฝํ•˜์—ฌ <WHAT>์˜ Prefix๋กœ ์‚ฌ์šฉ
  • PascalCase ํ˜•ํƒœ์˜ View๋Š” ๋Œ€๋ฌธ์ž ์ถ•์•ฝ
    • ex) TextView -> tv_
  • View์˜ ์ด๋ฆ„์ด Space, Switch ์™€ ๊ฐ™์ด ๋Œ€๋ฌธ์ž๊ฐ€ 1๊ฐœ๋งŒ ์กด์žฌํ•˜๋ฉด ๋ชจ๋‘ ์†Œ๋ฌธ์ž๋กœ ํ‘œํ˜„
    • ex) Switch -> switch_

<WHAT>

View Prefix
TextView tv_
ImageView iv_
CheckBox cb_
RecyclerView rv_
EditText et_
ProgressBar pb_
FrameLayout fl_
NestedScrollView nsv_
Space space_
Switch switch_
AbcDeFgh adf_
Abcdef abcdef_

String

  • <WHERE>_<DESCRIPTION>
  • ๋‹ค์–‘ํ•œ ํ™”๋ฉด์—์„œ ์‚ฌ์šฉ๋˜๋Š” ํ…์ŠคํŠธ๋ผ๋ฉด all_<DESCRIPTION>
    • ex) all_yes : ๋„ค
    • ex) permission_dialog_camera_description: ์นด๋ฉ”๋ผ๊ถŒํ•œ์„ ์š”๊ตฌํ•˜๋Š” Dialog์˜ ์„ค๋ช…๋‚ด์šฉ

3. Class

UseCase

  • List๋ฅผ ๊ฐ€์ ธ์˜ค๋Š” ๊ฒฝ์šฐ UseCase์˜ ์ด๋ฆ„์€ GetXXXListUseCase ๋กœ ์ •์˜
    • s ๋กœ ํ‘œํ˜„ํ•˜๊ฒŒ ๋˜๋ฉด ๋‹จ์ˆ˜๋ฅผ ๊ฐ€์ ธ์˜ค๋Š” ํด๋ž˜์Šค์™€ ํ—ท๊ฐˆ๋ฆฌ๊ธฐ ๋•Œ๋ฌธ

Function

  • ํด๋ž˜์Šค์˜ ๋ชจ๋“  ๋ฐ˜ํ™˜ํ˜•(:<๋ฐ˜ํ™˜ํ˜•> = )์€ ํ‘œ๊ธฐ(= ์‚ฌ์šฉํ•˜๋”๋ผ๋„)
  • ํด๋ž˜์Šค์—์„œ return์ด single Expression ์ผ ๊ฒฝ์šฐ, Flow ํ•จ์ˆ˜๋“ค์€ <๋ฐ˜ํ™˜ํ˜•>: = ์‚ฌ์šฉ | Mapper ํ•จ์ˆ˜๋“ค์€ return ์‚ฌ์šฉํ•ด์„œ ๋ฐ˜ํ™˜ | map ํ•จ์ˆ˜ ์‚ฌ์šฉํ–ˆ์„ ๊ฒฝ์šฐ <๋ฐ˜ํ™˜ํ˜•>: = ..?

4. Hilt

    ์™ธ๋ถ€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ผ ๊ฒฝ์šฐ: @Provides | ์‚ฌ์šฉ์ž ์ •์˜ class: @Binds

image

๐Ÿ—ฃ๏ธ ๋ฐ๋ชจ

โš ๏ธ ์ด์Šˆ ๊ณต์œ 

๐Ÿ‘Ÿ ์ฃผ๊ฐ„ ์Šคํ”„๋ฆฐํŠธ

โ˜€๏ธ ๋ฐ์ผ๋ฆฌ ์Šคํฌ๋Ÿผ

๐Ÿ“‚ week2
๐Ÿ“‚ week3
๐Ÿ“‚ week4
๐Ÿ“‚ week5
๐Ÿ“‚ week6
Clone this wiki locally