Skip to content

Commit

Permalink
docs: slices-segments page translated into Korean
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaic4o committed Jan 13, 2025
1 parent ce829ce commit 21a33c6
Showing 1 changed file with 73 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
title: ์Šฌ๋ผ์ด์Šค์™€ ์„ธ๊ทธ๋จผํŠธ
sidebar_position: 2
pagination_next: reference/public-api
---

# ์Šฌ๋ผ์ด์Šค์™€ ์„ธ๊ทธ๋จผํŠธ

## ์Šฌ๋ผ์ด์Šค(Slices)

์Šฌ๋ผ์ด์Šค๋Š” Feature-Sliced Design์˜ ์กฐ์ง ๊ณ„์ธต์—์„œ ๋‘ ๋ฒˆ์งธ ์ˆ˜์ค€์— ํ•ด๋‹นํ•ฉ๋‹ˆ๋‹ค. ์Šฌ๋ผ์ด์Šค์˜ ์ฃผ์š” ๋ชฉ์ ์€ ์ œํ’ˆ, ๋น„์ฆˆ๋‹ˆ์Šค, ๋˜๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์˜๋ฏธ์— ๋”ฐ๋ผ ์ฝ”๋“œ๋ฅผ ์ฒด๊ณ„์ ์œผ๋กœ ๊ทธ๋ฃนํ™”ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

์Šฌ๋ผ์ด์Šค์˜ ์ด๋ฆ„์€ ํ‘œ์ค€ํ™”๋˜์–ด ์žˆ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ด๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ๋น„์ฆˆ๋‹ˆ์Šค ๋„๋ฉ”์ธ์— ๋”ฐ๋ผ ์ด๋ฆ„์ด ์ง์ ‘์ ์œผ๋กœ ๊ฒฐ์ •๋˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ์‚ฌ์ง„ ๊ฐค๋Ÿฌ๋ฆฌ ๊ฒฝ์šฐ, `photo`, `effects`, `gallery-page`์™€ ๊ฐ™์€ ์Šฌ๋ผ์ด์Šค๋ฅผ ๊ฐ€์งˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฐ˜๋ฉด ์†Œ์…œ ๋„คํŠธ์›Œํฌ๋Š” `post`, `comments`, `news-feed`์™€ ๊ฐ™์€ ์Šฌ๋ผ์ด์Šค๊ฐ€ ํ•„์š”ํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค.

Shared์™€ App ๋ ˆ์ด์–ด๋Š” ์Šฌ๋ผ์ด์Šค๋ฅผ ํฌํ•จํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. Shared๋Š” ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์„ ์ „ํ˜€ ํฌํ•จํ•˜์ง€ ์•Š์•„์•ผ ํ•˜๋ฉฐ, App์€ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ „๋ฐ˜๊ณผ ๊ด€๋ จ๋œ ์ฝ”๋“œ๋งŒ ํฌํ•จํ•ด์•ผ ํ•˜๋ฏ€๋กœ, ๋ณ„๋„์˜ ์Šฌ๋ผ์ด์Šค๋กœ ๋ถ„ํ• ๋  ํ•„์š”๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.

### Zero ๊ฒฐํ•ฉ๋„์™€ ๋†’์€ ์‘์ง‘๋„ {#zero-coupling-high-cohesion}

์Šฌ๋ผ์ด์Šค๋Š” ๋…๋ฆฝ์ ์ด๊ณ  ๋†’์€ ์‘์ง‘๋„๋ฅผ ๊ฐ€์ง„ ์ฝ”๋“œ ํŒŒ์ผ ๊ทธ๋ฃน์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์•„๋ž˜ ๊ทธ๋ž˜ํ”ฝ์€ _์‘์ง‘๋„_์™€ _๊ฒฐํ•ฉ๋„_๋ผ๋Š” ๋ณต์žกํ•œ ๊ฐœ๋…์„ ์‹œ๊ฐ์ ์œผ๋กœ ์ดํ•ดํ•˜๋Š” ๋ฐ ๋„์›€์„ ์ค„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

<figure>
<img src="/img/coupling-cohesion-light.svg#light-mode-only" alt="" />
<img src="/img/coupling-cohesion-dark.svg#dark-mode-only" alt="" />
<figcaption>
Image inspired by https://enterprisecraftsmanship.com/posts/cohesion-coupling-difference/
</figcaption>
</figure>

์ด์ƒ์ ์ธ ์Šฌ๋ผ์ด์Šค๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํŠน์ง•์„ ๊ฐ€์ง‘๋‹ˆ๋‹ค:
1. ๋…๋ฆฝ์  โ€” ๊ฐ™์€ ๋ ˆ์ด์–ด์˜ ๋‹ค๋ฅธ ์Šฌ๋ผ์ด์Šค์™€ ๊ฒฐํ•ฉ๋˜์ง€ ์•Š์Œ(์ œ๋กœ ๊ฒฐํ•ฉ๋„).
2. ์‘์ง‘๋„ ๋†’์Œ โ€” ์ฃผ์š” ๋ชฉ์ ๊ณผ ๊ด€๋ จ๋œ ๋Œ€๋ถ€๋ถ„์˜ ์ฝ”๋“œ๋ฅผ ํฌํ•จํ•จ.

์Šฌ๋ผ์ด์Šค์˜ ๋…๋ฆฝ์„ฑ์€ [๋ ˆ์ด์–ด์˜ ์ž„ํฌํŠธ ๊ทœ์น™][layers--import-rule]์— ์˜ํ•ด ๊ฐ•์ œ๋ฉ๋‹ˆ๋‹ค:

> _์Šฌ๋ผ์ด์Šค์˜ ๋ชจ๋“ˆ(ํŒŒ์ผ)์€ ์—„๊ฒฉํ•˜๊ฒŒ ์•„๋ž˜ ๋ ˆ์ด์–ด์— ์œ„์น˜ํ•œ ๋‹ค๋ฅธ ์Šฌ๋ผ์ด์Šค๋งŒ ์ž„ํฌํŠธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.._
### ์Šฌ๋ผ์ด์Šค(Slices)์˜ Public API ๊ทœ์น™

์Šฌ๋ผ์ด์Šค ๋‚ด๋ถ€์—์„œ๋Š” ์›ํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ์ฝ”๋“œ๋ฅผ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค๋งŒ, ์Šฌ๋ผ์ด์Šค๊ฐ€ ๋‹ค๋ฅธ ์Šฌ๋ผ์ด์Šค์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ์ข‹์€ Public API๋ฅผ ์ œ๊ณตํ•˜๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค. ์ด ์›์น™์€ **์Šฌ๋ผ์ด์Šค์˜ Public API ๊ทœ์น™**์— ์˜ํ•ด ๊ฐ•์ œ๋ฉ๋‹ˆ๋‹ค:

> _๋ชจ๋“  ์Šฌ๋ผ์ด์Šค(๊ทธ๋ฆฌ๊ณ  ์Šฌ๋ผ์ด์Šค๊ฐ€ ์—†๋Š” ๋ ˆ์ด์–ด์˜ ์„ธ๊ทธ๋จผํŠธ)๋Š” Public API ์ •์˜๋ฅผ ํฌํ•จํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค._
>
> _์Šฌ๋ผ์ด์Šค/์„ธ๊ทธ๋จผํŠธ ์™ธ๋ถ€์˜ ๋ชจ๋“ˆ์€ ์Šฌ๋ผ์ด์Šค/์„ธ๊ทธ๋จผํŠธ์˜ ๋‚ด๋ถ€ ํŒŒ์ผ ๊ตฌ์กฐ๊ฐ€ ์•„๋‹Œ Public API๋งŒ ์ฐธ์กฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค._
Public API์˜ ๊ทผ๊ฑฐ์™€ ์ƒ์„ฑ์— ๋Œ€ํ•œ ๋ชจ๋ฒ” ์‚ฌ๋ก€๋Š” [Public API ์ฐธ์กฐ][ref-public-api]์—์„œ ์ž์„ธํžˆ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

### ์Šฌ๋ผ์ด์Šค(Slices) ๊ทธ๋ฃน

๋ฐ€์ ‘ํ•˜๊ฒŒ ๊ด€๋ จ๋œ ์Šฌ๋ผ์ด์Šค๋“ค์€ ๊ตฌ์กฐ์ ์œผ๋กœ ํด๋” ๋‚ด์—์„œ ๊ทธ๋ฃนํ™”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ, ์ด ๊ฒฝ์šฐ์—๋„ ๋‹ค๋ฅธ ์Šฌ๋ผ์ด์Šค๋“ค๊ณผ ๋™์ผํ•œ ๊ฒฉ๋ฆฌ ๊ทœ์น™์„ ๋”ฐ๋ผ์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ฆ‰, ๊ทธ๋ฃน ๋‚ด์˜ ํด๋”์—์„œ๋Š” **์ฝ”๋“œ ๊ณต์œ ๊ฐ€ ์—†์–ด์•ผ** ํ•ฉ๋‹ˆ๋‹ค.

![Features "compose", "like" ๊ทธ๋ฆฌ๊ณ  "delete"๊ฐ€ "post" ํด๋”์— ๊ทธ๋ฃนํ™”๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ํ•ด๋‹น ํด๋”์—๋Š” ํ—ˆ์šฉ๋˜์ง€ ์•Š์Œ์„ ๋‚˜ํƒ€๋‚ด๊ธฐ ์œ„ํ•ด ์ทจ์†Œ์„ ์ด ๊ทธ์–ด์ง„ "some-shared-code.ts" ํŒŒ์ผ๋„ ์žˆ์Šต๋‹ˆ๋‹ค.](/img/graphic-nested-slices.svg)

## ์„ธ๊ทธ๋จผํŠธ(Segments)

์„ธ๊ทธ๋จผํŠธ๋Š” ์กฐ์ง ๊ณ„์ธต์˜ ์„ธ ๋ฒˆ์งธ์ด์ž ๋งˆ์ง€๋ง‰ ์ˆ˜์ค€์œผ๋กœ, ๊ธฐ์ˆ ์  ํŠน์„ฑ์— ๋”ฐ๋ผ ์ฝ”๋“œ๋ฅผ ๊ทธ๋ฃนํ™”ํ•˜๋Š” ๊ฒƒ์„ ๋ชฉ์ ์œผ๋กœ ํ•ฉ๋‹ˆ๋‹ค.

ํ‘œ์ค€ํ™”๋œ ์„ธ๊ทธ๋จผํŠธ ์ด๋ฆ„์ž…๋‹ˆ๋‹ค:

- `ui` โ€” UI ํ‘œ์‹œ์™€ ๊ด€๋ จ๋œ ๋ชจ๋“  ๊ฒƒ: UI ์ปดํฌ๋„ŒํŠธ, ๋‚ ์งœ ํฌ๋งคํ„ฐ, ์Šคํƒ€์ผ ๋“ฑ
- `api` โ€” ๋ฐฑ์—”๋“œ ์ƒํ˜ธ์ž‘์šฉ: ์š”์ฒญ ํ•จ์ˆ˜, ๋ฐ์ดํ„ฐ ํƒ€์ž…, ๋งคํผ ๋“ฑ
- `model` โ€” ๋ฐ์ดํ„ฐ ๋ชจ๋ธ: ์Šคํ‚ค๋งˆ, ์ธํ„ฐํŽ˜์ด์Šค, ์Šคํ† ์–ด, ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง
- `lib` โ€” ์ด ์Šฌ๋ผ์ด์Šค์˜ ๋‹ค๋ฅธ ๋ชจ๋“ˆ์—์„œ ํ•„์š”๋กœ ํ•˜๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ฝ”๋“œ
- `config` โ€” ์„ค์ • ํŒŒ์ผ๊ณผ ๊ธฐ๋Šฅ ํ”Œ๋ž˜๊ทธ

๊ฐ ๋ ˆ์ด์–ด(Layer)์—์„œ ์ด๋Ÿฌํ•œ ์„ธ๊ทธ๋จผํŠธ๊ฐ€ ์–ด๋–ป๊ฒŒ ์‚ฌ์šฉ๋˜๋Š”์ง€์— ๋Œ€ํ•œ ๋” ์ž์„ธํ•œ ์ •๋ณด๋Š” [๋ ˆ์ด์–ด ํŽ˜์ด์ง€][layers--layer-definitions]๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”.

์‚ฌ์šฉ์ž ์ •์˜ ์„ธ๊ทธ๋จผํŠธ๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž ์ •์˜ ์„ธ๊ทธ๋จผํŠธ๋Š” ์Šฌ๋ผ์ด์Šค๊ฐ€ ์—†๋Š” App ๋ ˆ์ด์–ด์™€ Shared ๋ ˆ์ด์–ด์—์„œ ๊ฐ€์žฅ ํ”ํžˆ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

์„ธ๊ทธ๋จผํŠธ ์ด๋ฆ„์€ ์ฝ”๋“œ์˜ ๋ชฉ์ ์„ ์„ค๋ช…ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, `components`, `hooks`, `types`์™€ ๊ฐ™์€ ์ด๋ฆ„์€ ์ฝ”๋“œ๋ฅผ ์ฐพ๋Š” ๋ฐ ๋น„ํšจ์œจ์ ์ด๋ฏ€๋กœ ์‚ฌ์šฉ์„ ํ”ผํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

[layers--layer-definitions]: /docs/reference/layers#layer-definitions
[layers--import-rule]: /docs/reference/layers#import-rule-on-layers
[ref-public-api]: /docs/reference/public-api

0 comments on commit 21a33c6

Please sign in to comment.