Skip to content
This repository has been archived by the owner on May 26, 2021. It is now read-only.

Code Convention

Kang min gu edited this page Jul 3, 2020 · 6 revisions

๐Ÿ“— Code Convention

๋ณ€์ˆ˜ ํ‘œ๊ธฐ : ์นด๋ฉœ ํ‘œ๊ธฐ๋ฒ•

  • ์ „์—ญ ๋ณ€์ˆ˜ : m์œผ๋กœ ์‹œ์ž‘ํ•˜๋Š” ์นด๋ฉœ ํ‘œ๊ธฐ๋ฒ•

    • ์ƒ์ˆ˜ : ํŒŒ์Šค์นผ ํ‘œ๊ธฐ๋ฒ•

Class, Object, Interface ํ‘œ๊ธฐ : ํŒŒ์Šค์นผ ํ‘œ๊ธฐ๋ฒ•

  • Interface : ํŒŒ์Šค์นผ๋กœ ํ‘œ๊ธฐํ•˜๋˜ ๋งˆ์ง€๋ง‰์— Interface ๋ถ™์—ฌ์ค„ ๊ฒƒ

    • Data Class : ํŒŒ์Šค์นผ๋กœ ํ‘œ๊ธฐํ•˜๋˜ ๋งˆ์ง€๋ง‰์— Data ๋ถ™์—ฌ์ค„ ๊ฒƒ

      • ์ด๋ฆ„์„ ๋”ฑ ๋ด๋„ ๋ฌด์Šจ ๊ธฐ๋Šฅ์ธ์ง€ ์•Œ ์ˆ˜ ์žˆ๊ฒŒ ํ‘œ์‹œ, ์ค„์ž„๋ง ์ตœ๋Œ€ํ•œ ์ž์ œ.

ํ•จ์ˆ˜ ํ‘œ๊ธฐ : ์นด๋ฉœ ํ‘œ๊ธฐ๋ฒ•

  • Class, Object, Interface ์ž‘์„ฑ๊ณผ ๋™์ผ

๋””๋ ‰ํ† ๋ฆฌ ํ‘œ๊ธฐ : ์†Œ๋ฌธ์ž ํ‘œ๊ธฐ

  • ์ค„์ž„๋ง ์“ฐ์ง€ ์•Š๊ธฐ ( ex. ๋ทฐํ™€๋” ๋””๋ ‰ํ† ๋ฆฌ -> vh (X) )

xml ํ‘œ๊ธฐ : ์Šค๋„ค์ดํฌ ํ‘œ๊ธฐ

๋ทฐ id ํ‘œ๊ธฐ : ์Šค๋„ค์ดํฌ ํ‘œ๊ธฐ

  • ์œ„์ ฏ_ํ”„๋ž˜๊ทธ๋จผํŠธor์•กํ‹ฐ๋น„ํ‹ฐ ์ด๋ฆ„_๋ทฐ์˜ ์—ญํ•  ( ex. btn_law_register )

์œ„์ ฏ ํ‘œ๊ธฐ

  • Button : btn

  • TextView : txt

  • EditTextView : edt

  • ImageView : img

  • RecycelerView : rcv

  • ViewPager : vp

๋งค๊ฐœ๋ณ€์ˆ˜ : ์•ˆ๋“œ๋กœ์ด๋“œ ์ŠคํŠœ๋””์˜ค ๊ฐ€์ด๋“œ๋ผ์ธ์„ ๋„˜๊ธธ ์‹œ, ๋ชจ๋“  ๋งค๊ฐœ ๋ณ€์ˆ˜ ์—”ํ„ฐ๋กœ ๊ฐœํ–‰

  • ์˜ˆ์‹œ
override fun getItemOffsets(
       outRect: Rect,
       view: View,
       parent: RecyclerView,
       state: RecyclerView.State) {
       with(outRect) {
           if (parent.getChildAdapterPosition(view) == 0) {
               top = spaceHeight
           }
           left =  spaceHeight
           right = spaceHeight
           bottom = spaceHeight
       }
   }