Published on

๐Ÿค”Naming Convention(๋„ค์ด๋ฐ ์ปจ๋ฒค์…˜)์ด๋ž€ ๋ฌด์—‡์ผ๊นŒ?

Authors

Naming Convention(๋„ค์ด๋ฐ ์ปจ๋ฒค์…˜) ์ด๋ž€?

ํ”„๋กœ๊ทธ๋ž˜๋ฐ์„ ํ•˜๋‹ค๋ณด๋ฉด ๋‹ค์–‘ํ•œ ์‹๋ณ„์ž๊ฐ€ ์‚ฌ์šฉ๋˜๋ฉฐ, ํ•ด๋‹น ์‹๋ณ„์ž๋“ค์€ ๋ฌธ์ž์—ด ๋ช…์นญ์œผ๋กœ ๊ตฌ๋ถ„๋œ๋‹ค. ํ˜„๋Œ€ ์‚ฌํšŒ ์† ํ”„๋กœ๊ทธ๋žจ๋“ค์€ ๊ทœ๋ชจ์™€ ๋ณต์žก์„ฑ์ด ๋น„๋Œ€ํ•ด ์กŒ๊ณ , ๋”ฐ๋ผ์„œ ๋‹ค์–‘ํ•œ ์‚ฌ๋žŒ๋“ค๊ณผ ํ•จ๊ป˜ ํž˜์„ ํ•ฉ์ณ ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜๋Š” ์ƒํ™ฉ์ด ํ‘œ์ค€ ์ƒํƒœ์ด๋‹ค. ์ด๋Ÿฌํ•œ ๊ฐœ๋ฐœ ๊ณผ์ • ์ค‘, ์‹๋ณ„์ž์˜ ์„ฑ์งˆ์— ๋”ฐ๋ผ ๋ช…์นญ์— ๊ทœ์น™์„ ์„ธ์šฐ๊ฒŒ ๋˜์—ˆ๊ณ , ํ•ด๋‹น ๊ทœ์น™์„ Naming Convention, ๋„ค์ด๋ฐ ์ปจ๋ฒค์…˜ ์ด๋ผ๊ณ  ๋ถ€๋ฅธ๋‹ค. ์ง์—ญ ํ•˜๋ฉด ๋ช…๋ช… ๊ทœ์น™, ๋ช…๋ช… ๊ทœ์•ฝ์œผ๋กœ ํ•ด์„ ํ•  ์ˆ˜์žˆ๋‹ค.

Naming Convention(๋„ค์ด๋ฐ ์ปจ๋ฒค์…˜)์˜ ์žฅ์ 

์œ„ํ‚ค ๋ฌธ์„œ์—์„œ๋Š” ๋‹ค์Œ์˜ 3๊ฐ€์ง€ ์‚ฌํ•ญ์„ ๊ฐ€์žฅ ํฐ ์žฅ์ ์œผ๋กœ ์ œ์‹œํ•œ๋‹ค.

  • ๊ฐ€๋…์„ฑ (legibility)

    ๋ฌธ์ž, ๊ธฐํ˜ธ ๋˜๋Š” ๋„ํ˜•์ด ์–ผ๋งˆ๋‚˜ ์‰ฝ๊ฒŒ ์ฝํžˆ๋Š”๊ฐ€ ํ•˜๋Š” ๋Šฅ๋ฅ ์˜ ์ •๋„. ์ƒ‰์ฑ„์˜ ๊ฒฝ์šฐ ์‹œ์ธ์„ฑ ํ˜น์€ ๋ช…์‹œ์„ฑ์ด ๋†’์•„ ๋ฉ€๋ฆฌ์„œ๋„ ์ž˜ ๋ณด์ด๋Š” ์ •๋„๋ฅผ ๋งํ•œ๋‹ค. ๋ช…์‹œ์„ฑ์„ ๋†’์ด๋ ค๋ฉด ๋ช…๋„ ์ฐจ๋ฅผ ๋‘์–ด ๋ฐฐ์ƒ‰ํ•˜๊ณ , ๋ช…์‹œ์„ฑ์ด ๊ฐ€์žฅ ๋†’์€ ๋ฐฐ์ƒ‰์€ ๋…ธ๋ž€ ๋ฐฐ๊ฒฝ์— ๊ฒ€์€ ๊ธ€์”จ์ด๋‹ค.
    [๋„ค์ด๋ฒ„ ์ง€์‹๋ฐฑ๊ณผ]

  • ์‹œ์ธ์„ฑ (Visibility

    ๋Œ€์ƒ๋ฌผ์˜ ์กด์žฌ ๋˜๋Š” ๋ชจ์–‘์ด ์›๊ฑฐ๋ฆฌ์—์„œ๋„ ์‹๋ณ„์ด ์‰ฌ์šด ์„ฑ์งˆ. ์œ ๋ชฉ์„ฑ ํ˜น์€ ์ฃผ๋ชฉ์„ฑ๊ณผ ๊ตฌ๋ณ„๋˜๋ฉฐ, ๋ช…๋„ ์ฐจ๊ฐ€ ํด์ˆ˜๋ก ์‹œ์ธ์„ฑ์ด ๋†’๋‹ค.
    [๋„ค์ด๋ฒ„ ์ง€์‹๋ฐฑ๊ณผ]

  • ํšจ์œจ์„ฑ (efficiency)

    ๋“ค์ธ ๋…ธ๋ ฅ๊ณผ ์–ป์€ ๊ฒฐ๊ณผ์˜ ๋น„์œจ์ด ๋†’์€ ํŠน์„ฑ. [๋„ค์ด๋ฒ„ ์ง€์‹๋ฐฑ๊ณผ]

ํ˜‘์—… ํ™˜๊ฒฝ ์† ํ”„๋กœ๊ทธ๋žจ ์†Œ์Šค์ฝ”๋“œ ์ž‘์„ฑ๊ณผ ์‚ฌํ›„ ๊ด€๋ฆฌ์— ๋Šฅ๋ฅ ๊ณผ ํŽธ์˜์„ฑ์„ ํ–ฅ์ƒ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋‹ค.

Naming Convention(๋„ค์ด๋ฐ ์ปจ๋ฒค์…˜)์˜ ์˜ˆ์‹œ

1. Camel case

ํ”„๋กœ๊ทธ๋ž˜๋ฐ์—์„œ ํŒŒ์ผ, ๋ณ€์ˆ˜, ํ•จ์ˆ˜ ๋“ฑ ๋Œ€์ƒ์˜ ์ด๋ฆ„์„ ๋„์–ด์“ฐ๊ธฐ ์—†์ด ์ง“๊ธฐ ์œ„ํ•˜์—ฌ ๋”ฐ๋ฅด๋Š” ๊ด€๋ก€

  • Upper camel case(== Pascal case)
    ํŒŒ์Šค์นผ ์ผ€์ด์Šค๋ผ๊ณ  ๋งŽ์ด ๋ถˆ๋ฆฌ์šฐ๋Š” ๋„ค์ด๋ฐ ์ปจ๋ฒค์…˜. ์ฒซ ๋‹จ์–ด๋ถ€ํ„ฐ ๊ฐ ๋‹จ์–ด์˜ ์‹œ์ž‘ ์•ŒํŒŒ๋ฒณ์„ ๋Œ€๋ฌธ์ž๋กœ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค. ๋‹จ์–ด์™€ ๋‹จ์–ด ์‚ฌ์ด๋Š” ๋ชจ๋‘ ์—ฐ๊ฒฐํ•œ๋‹ค.

ํด๋ž˜์Šค๋ช…์— ๋งŽ์ด ์‚ฌ์šฉ๋œ๋‹ค.

์›๋ฌธ : infinite programming language
ํŒŒ์Šค์นผ ์ผ€์ด์Šค : InfiniteProgrammingLanguage
  • Lower camel case(== Dromedary case)
    ์นด๋ฉœ ์ผ€์ด์Šค๋ผ๊ณ  ๋งŽ์ด ๋ถˆ๋ฆฌ์šฐ๋Š” ๋„ค์ด๋ฐ ์ปจ๋ฒค์…˜. ๋‚™ํƒ€์˜ ๋“ฑ ๋ชจ์–‘์—์„œ ๋”ฐ์˜จ ๋ฐฉ๋ฒ•์ด๋‹ค. ์ฒซ ๋‹จ์–ด๋Š” ์†Œ๋ฌธ์ž, ๋‘๋ฒˆ์งธ ๋‹จ์–ด๋ถ€ํ„ฐ ๋Œ€๋ฌธ์ž๋กœ ์‚ฌ์šฉํ•œ๋‹ค. ๋‹จ์–ด์™€ ๋‹จ์–ด ์‚ฌ์ด๋Š” ๋ชจ๋‘ ์—ฐ๊ฒฐํ•œ๋‹ค.

๋ณ€์ˆ˜๋ช…, ํ•จ์ˆ˜๋ช…์— ๋งŽ์ด ์‚ฌ์šฉ๋œ๋‹ค.

์›๋ฌธ : infinite programming language
๋กœ์šฐ ์ผ€์ด์Šค : infinteProgrammingLanguage

2. Hungarian notation

์ปดํ“จํ„ฐ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์—์„œ ๋ณ€์ˆ˜๋‚˜ ํ•จ์ˆ˜์˜ ์ด๋ฆ„์— ๊ทธ ์ข…๋ฅ˜, ๊ณง ํ”ํžˆ ๋ฐ์ดํ„ฐ ํƒ€์ž… ๋”ฐ์œ„๋ฅผ ๋ช…์‹œํ•˜๋Š” ํ‘œ๊ธฐ๋ฒ•์œผ๋กœ, ๋ช…๋ช…๊ทœ์น™์˜ ์ผ์ข…์ด๋‹ค. ์ตœ๊ทผ์—๋Š” ๋””์Šคํ”Œ๋ ˆ์ด ํ™”๋ฉด๋„ ์ปค์ง€๊ณ  IDE๊ฐ€ ๋ฐœ์ „ํ•˜์—ฌ์„œ ๋งŽ์ด ์‚ฌ์šฉ ๋˜์ง€ ์•Š๋Š”๋‹ค.

์˜ˆ์‹œ : strName, nStudentnumber

3. Snake case

๋ฐ”๋‹ฅ์„ ๊ธฐ์–ด๋‹ค๋‹ˆ๋Š” ๋ฑ€์˜ ๋ชจ์Šต์„ ๋”ฐ์˜จ ๋„ค์ด๋ฐ ์ปจ๋ฒค์…˜. ๋‹จ์–ด์™€ ๋‹จ์–ด ์‚ฌ์ด๋ฅผ ์–ธ๋” ๋ฐ”(_)๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋„์›Œ์„œ ํ‘œ๊ธฐํ•œ๋‹ค.

ํŒŒ์ผ๋ช…์— ๋งŽ์ด ์“ฐ์ž„

์›๋ฌธ : infinite programming language
์Šค๋„ค์ดํฌ ์ผ€์ด์Šค : infinite_programming_language

4. Kebab case

์ผ€๋ฐฅ์ด ๊ผฌ์ฑ™์ด๊ฒŒ ๊ฝ‚ํžˆ ๋ชจ์Šต์—์„œ ์ƒ๊ธด ๋ฐฉ๋ฒ•. ๋ชจ๋“  ๋‹จ์–ด๊ฐ€ ์†Œ๋ฌธ์ž ์‹œ์ž‘, ๋‹จ์–ด์™€ ๋‹จ์–ด ์‚ฌ์ด "-"๋กœ ์—ฐ๊ฒฐ

์›๋ฌธ : infinite programming language
์ผ€๋ฐฅ ์ผ€์ด์Šค : infinite-programming-language