Skip to content

๐Ÿ‘ฎ๐Ÿป ์ฝ”๋“œ ์ปจ๋ฒค์…˜

Sujong Kwak edited this page Nov 1, 2024 · 1 revision

๐Ÿ“Œ ๋„ค์ด๋ฐ ์ปจ๋ฒค์…˜

ํด๋”: lower-kebap-case

  • ์ผ€๋ฐฅ ์ผ€์ด์Šค (kebab-case)๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํด๋” ์ด๋ฆ„์„ ์ž‘์„ฑํ•ด์š”.
  • ์ผ๋ฐ˜์ ์œผ๋กœ ์ปดํฌ๋„ŒํŠธ, ํŽ˜์ด์ง€, ํ›… ๋“ฑ์˜ ํด๋”๋ฅผ ๊ตฌ์กฐํ™”ํ•˜๋ฉฐ, ํด๋”๋ช…์€ ๋ชจ๋‘ ์†Œ๋ฌธ์ž๋กœ ์ž‘์„ฑํ•˜๋Š” ๊ฒƒ์„ ์›์น™์œผ๋กœ ํ•ด์š”.

ํŒŒ์ผ: camelCase, PascalCase

  • ์ปดํฌ๋„ŒํŠธ ํŒŒ์ผ: ํŒŒ์Šค์นผ ์ผ€์ด์Šค (PascalCase) ์‚ฌ์šฉํ•ด์š”.

    Button.jsx, HomePage.jsx์ฒ˜๋Ÿผ, ๊ฐ ์ปดํฌ๋„ŒํŠธ ํŒŒ์ผ์€ ์ฒซ ๊ธ€์ž๋ฅผ ๋Œ€๋ฌธ์ž๋กœ ํ•˜๊ณ  ํŒŒ์Šค์นผ ์ผ€์ด์Šค๋กœ ์ž‘์„ฑํ•˜์—ฌ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋ช…ํ™•ํ•˜๊ฒŒ ๊ตฌ๋ถ„ํ•ด์š”.

  • ์ผ๋ฐ˜ ํŒŒ์ผ (์œ ํ‹ธ๋ฆฌํ‹ฐ ํ•จ์ˆ˜, API ํŒŒ์ผ ๋“ฑ): ์นด๋ฉœ ์ผ€์ด์Šค (camelCase) ์‚ฌ์šฉํ•ด์š”.

    formatDate.js, useFetch.js์™€ ๊ฐ™์ด, ์ผ๋ฐ˜ ํŒŒ์ผ์€ ํ•จ์ˆ˜๋ช…์ฒ˜๋Ÿผ ์นด๋ฉœ ์ผ€์ด์Šค๋ฅผ ์‚ฌ์šฉํ•ด ๊ตฌ๋ถ„ํ•ด์š”.

  • ์ค„์ž„๋ง์€ ๊ธˆ์ง€! ํ•˜๊ธฐ๋กœ ์•ฝ์†ํ–ˆ์–ด์š”. (์˜ˆ : idx โ†’ index)

ํ•จ์ˆ˜: camelCase

  • ๋™์‚ฌ + ๋ช…์‚ฌ: ํ•จ์ˆ˜๋ช…์€ ๋™์‚ฌ + ๋ช…์‚ฌ ํ˜•ํƒœ๋กœ, ํ•จ์ˆ˜์˜ ๋™์ž‘๊ณผ ๋Œ€์ƒ์ด ๋ช…ํ™•ํžˆ ํ•ด์•ผํ•ด์š”.
    • ์˜ˆ์‹œ: getUserInfo, updateProductList, calculateTotalPrice
  • ์นด๋ฉœ ์ผ€์ด์Šค: ํ•จ์ˆ˜๋ช…๋„ ์ฒซ ๊ธ€์ž๋ฅผ ์†Œ๋ฌธ์ž๋กœ ์‹œ์ž‘ํ•˜๋ฉฐ, ๋‹จ์–ด์˜ ์ฒซ ๊ธ€์ž๋Š” ๋Œ€๋ฌธ์ž๋กœ ์ž‘์„ฑํ•ด์š”.
    • ์˜ˆ์‹œ: fetchData, saveUserData, resetForm

๋ณ€์ˆ˜: camelCase

  • ๋ช…์‚ฌ + ๋ช…์‚ฌ: ๋‘ ๊ฐœ ์ด์ƒ์˜ ๋‹จ์–ด๋กœ ๊ตฌ์„ฑ๋œ ๋ณ€์ˆ˜๋ช…์€ ๋ช…์‚ฌ + ๋ช…์‚ฌ ํ˜•ํƒœ๋กœ ์ž‘์„ฑํ•ด์š”.
    • ์˜ˆ์‹œ: userList, productDetails, orderHistory
  • ์นด๋ฉœ ์ผ€์ด์Šค: ๋ณ€์ˆ˜๋ช…์€ ์ฒซ ๊ธ€์ž๋ฅผ ์†Œ๋ฌธ์ž๋กœ ์‹œ์ž‘ํ•˜๊ณ , ๋‹จ์–ด์˜ ์ฒซ ๊ธ€์ž๋Š” ๋Œ€๋ฌธ์ž๋กœ ํ‘œ๊ธฐํ•ด์š”.
    • ์˜ˆ์‹œ: totalPrice, userProfile, orderId

๊ธฐํƒ€:

  • Boolean ๋ณ€์ˆ˜: ์ฐธ/๊ฑฐ์ง“์„ ๋‚˜ํƒ€๋‚ด๋Š” ๋ณ€์ˆ˜๋Š” is, has, can ๋“ฑ์˜ ์ ‘๋‘์‚ฌ๋ฅผ ์‚ฌ์šฉ, Boolean์ž„์„ ๋ช…ํ™•ํžˆ ํ•ด์•ผํ•ด์š”.
    • ์˜ˆ์‹œ: isLoggedIn, hasPermission, canEdit
  • Boolean ํ•จ์ˆ˜: ์ฐธ/๊ฑฐ์ง“์„ ๋ฆฌํ„ดํ•˜๋Š” ํ•จ์ˆ˜๋Š” check ์ ‘๋‘์‚ฌ๋ฅผ ์‚ฌ์šฉ.
    • ์˜ˆ์‹œ: checkLoggedIn, checkPermission, checkEditable
  • ์ƒ์ˆ˜: ์ƒ์ˆ˜๋ช…์€ ๋ชจ๋“  ๊ธ€์ž๋ฅผ ๋Œ€๋ฌธ์ž๋กœ ์ž‘์„ฑํ•˜๋ฉฐ, ๋‹จ์–ด ์‚ฌ์ด์— _ ์‚ฌ์šฉ.
    • ์˜ˆ์‹œ: MAX_RETRY_COUNT, API_BASE_URL, DEFAULT_TIMEOUT

FE

ํ•ญ๋ชฉ ์˜ˆ์‹œ ๋„ค์ด๋ฐ ๊ทœ์น™
์ปดํฌ๋„ŒํŠธ ํด๋” button/, header/ ์ผ€๋ฐฅ ์ผ€์ด์Šค
์ปดํฌ๋„ŒํŠธ ํŒŒ์ผ Button.jsx ํŒŒ์Šค์นผ ์ผ€์ด์Šค
ํŽ˜์ด์ง€ ์ปดํฌ๋„ŒํŠธ Home.jsx, About.jsx ํŒŒ์Šค์นผ ์ผ€์ด์Šค
์ผ๋ฐ˜ ํ•จ์ˆ˜ ๋ฐ ์œ ํ‹ธ๋ฆฌํ‹ฐ formatDate.js ์นด๋ฉœ ์ผ€์ด์Šค
์ปค์Šคํ…€ ํ›… ํŒŒ์ผ useFetch.js ์นด๋ฉœ ์ผ€์ด์Šค
์Šคํƒ€์ผ ํŒŒ์ผ Button.css ์ปดํฌ๋„ŒํŠธ ์ด๋ฆ„๊ณผ ๋™์ผ

BE

ํ•ญ๋ชฉ ์˜ˆ์‹œ ๋„ค์ด๋ฐ ๊ทœ์น™
๋ผ์šฐํŠธ ํŒŒ์ผ userRoutes.js ์นด๋ฉœ ์ผ€์ด์Šค
์ปจํŠธ๋กค๋Ÿฌ ํŒŒ์ผ userController.js ์นด๋ฉœ ์ผ€์ด์Šค
๋ชจ๋ธ ํŒŒ์ผ userModel.js ์นด๋ฉœ ์ผ€์ด์Šค
๋ฏธ๋“ค์›จ์–ด ํŒŒ์ผ authMiddleware.js ์นด๋ฉœ ์ผ€์ด์Šค
์„œ๋น„์Šค ํŒŒ์ผ userService.js ์นด๋ฉœ ์ผ€์ด์Šค
์œ ํ‹ธ๋ฆฌํ‹ฐ ํŒŒ์ผ formatDate.js ์นด๋ฉœ ์ผ€์ด์Šค
ํด๋” controllers, models ์ผ€๋ฐฅ ์ผ€์ด์Šค

๐Ÿ“Œ ์ฝ”๋“œ ๋ฌธ์„œํ™” ์ปจ๋ฒค์…˜

(์ฃผ์„, API ๋ฌธ์„œํ™”, readme ๊ทœ์น™ ๋“ฑ)

์ปดํฌ๋„ŒํŠธ: Storybook

  • ์Šคํ† ๋ฆฌ๋ถ์œผ๋กœ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋ฌธ์„œํ™”ํ•˜๊ณ , ์Šคํ† ๋ฆฌ๋ถ ์ฝ”๋“œ๋Š” ๊ฐ™์€ ๋””๋ ‰ํ† ๋ฆฌ์— ์ž‘์„ฑํ•ด์š”.

util ํ•จ์ˆ˜, ์ปค์Šคํ…€ ํ›…: TypeDoc

  • TSDoc ์ฃผ์„์„ ํ†ตํ•ด util ํ•จ์ˆ˜, ์ปค์Šคํ…€ํ›…์„ TypeDoc์œผ๋กœ ๋ฌธ์„œํ™”ํ•  ์ˆ˜ ์žˆ๋„๋ก ์ž‘์„ฑํ•ด์š”.

  • ์˜ˆ์‹œ ์ฝ”๋“œ:

/**
 * ์ฃผ์–ด์ง„ ๋‚ ์งœ๋ฅผ ์›ํ•˜๋Š” ํ˜•์‹์˜ ๋ฌธ์ž์—ด๋กœ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
 * @description
 * ์ง€์›ํ•˜๋Š” ํฌ๋งท:
 * - 'YYYY-MM-DD'
 * - 'MM/DD/YYYY'
 * - 'DD-MM-YYYY'
 * 
 * @param date - ๋ณ€ํ™˜ํ•  Date ๊ฐ์ฒด
 * @param format - ์›ํ•˜๋Š” ๋‚ ์งœ ํ˜•์‹ (๊ธฐ๋ณธ๊ฐ’: 'YYYY-MM-DD')
 * @returns ํฌ๋งท๋œ ๋‚ ์งœ ๋ฌธ์ž์—ด
 * 
 * @example
 * const date = new Date('2024-01-01');
 * const formatted = formatDate(date, 'MM/DD/YYYY');
 * console.log(formatted); // "01/01/2024"
 */
export const formatDate = (date: Date, format: string = 'YYYY-MM-DD'): string => {
  const year = date.getFullYear();
  const month = String(date.getMonth() + 1).padStart(2, '0');
  const day = String(date.getDate()).padStart(2, '0');
  return format
    .replace('YYYY', year.toString())
    .replace('MM', month)
    .replace('DD', day);
};

๐Ÿ˜Ž ์›จ๋ฒ ๋ฒ ๋ฒ ๋ฒฑ

๐Ÿ‘ฎ๐Ÿป ํŒ€ ๊ทœ์น™

๐Ÿ’ป ํ”„๋กœ์ ํŠธ

๐Ÿชต ์›จ๋ฒ ๋ฒฑ ๊ธฐ์ˆ ๋กœ๊ทธ

๐Ÿช„ ๋ฐ๋ชจ ๊ณต์œ 

๐Ÿ”„ ์Šคํ”„๋ฆฐํŠธ ๊ธฐ๋ก

๐Ÿ“— ํšŒ์˜๋ก

Clone this wiki locally