๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

์ปดํฌ์ง€ํŠธ1

[๋””์ž์ธํŒจํ„ด] ์ปดํฌ์ง€ํŠธ(Composite) ํŒจํ„ด ์ปดํฌ์ง€ํŠธ ํŒจํ„ด(Composite Pattern)*์ปดํฌ์ง€ํŠธ ํŒจํ„ด(Composite Pattern)**์€ ๊ตฌ์กฐ์  ๋””์ž์ธ ํŒจํ„ด ์ค‘ ํ•˜๋‚˜๋กœ, ๊ฐ์ฒด๋ฅผ ํŠธ๋ฆฌ ๊ตฌ์กฐ๋กœ ๊ตฌ์„ฑํ•˜์—ฌ ๋ถ€๋ถ„-์ „์ฒด ๊ณ„์ธต์„ ํ‘œํ˜„ํ•  ๋•Œ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ์ด ํŒจํ„ด์€ ํด๋ผ์ด์–ธํŠธ๊ฐ€ ๋‹จ์ผ ๊ฐ์ฒด์™€ ๋ณตํ•ฉ ๊ฐ์ฒด๋ฅผ ๋™์ผํ•œ ๋ฐฉ์‹์œผ๋กœ ๋‹ค๋ฃฐ ์ˆ˜ ์žˆ๋„๋ก ํ•ด์ค๋‹ˆ๋‹ค. ์ฆ‰, ๊ฐœ๋ณ„ ๊ฐ์ฒด(Leaf)์™€ ๋ณตํ•ฉ ๊ฐ์ฒด(Composite)๋ฅผ ๋™์ผํ•œ ์ธํ„ฐํŽ˜์ด์Šค๋กœ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.1. ์ปดํฌ์ง€ํŠธ ํŒจํ„ด์˜ ๊ธฐ๋ณธ ๊ฐœ๋…๊ตฌ์„ฑ ์š”์†Œ:Component: ๊ฐ์ฒด๋“ค ๊ฐ„์˜ ๊ณตํ†ต ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์—๋Š” Leaf์™€ Composite์—์„œ ๊ณตํ†ต์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๋ฉ”์„œ๋“œ๊ฐ€ ํฌํ•จ๋ฉ๋‹ˆ๋‹ค.Leaf: ํŠธ๋ฆฌ์˜ ๋ง๋‹จ ๋…ธ๋“œ๋ฅผ ํ‘œํ˜„ํ•˜๋ฉฐ, ๋” ์ด์ƒ ์ž์‹์„ ๊ฐ€์ง€์ง€ ์•Š๋Š” ๊ฐ์ฒด์ž…๋‹ˆ๋‹ค. Component ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค.Compos.. 2024. 8. 25.