๐Ÿ—บ๏ธ Design Pattern

๐Ÿ—บ๏ธ Design Pattern

[Design Pattern] Flyweight Pattern - ํ”Œ๋ผ์ด์›จ์ดํŠธ ํŒจํ„ด

Flyweight Patternํ”Œ๋ผ์ด์›จ์ดํŠธ ํŒจํ„ด(Flyweight Pattern)์€ ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ์„ ์ค„์ด๊ธฐ ์œ„ํ•ด ๋งŽ์€ ์ˆ˜์˜ ์ž‘์€ ๊ฐ์ฒด๋ฅผ ๊ณต์œ ํ•˜๋Š” ๋””์ž์ธ ํŒจํ„ด์ž…๋‹ˆ๋‹ค. ์ด ํŒจํ„ด์€ ๊ฐ์ฒด์˜ ์ƒํƒœ๋ฅผ ๋‚ด์  ์ƒํƒœ์™€ ์™ธ์  ์ƒํƒœ๋กœ ๋‚˜๋ˆ„์–ด, ๋‚ด์  ์ƒํƒœ๋ฅผ ๊ณต์œ ํ•˜์—ฌ ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ์„ ์ตœ์ ํ™”ํ•ฉ๋‹ˆ๋‹ค.Flyweight Pattern → ๋™์ผํ•œ ๊ฒƒ์„ ๊ณต์œ ํ•ด์„œ ๋‚ญ๋น„๋ฅผ ์—†์•ค๋‹ค๋Š” ํŠน์ง•์ด ์žˆ์Šต๋‹ˆ๋‹ค.Flyweight๋Š” ํ”Œ๋ผ์ด๊ธ‰ ์ด๋ผ๋Š” ์˜๋ฏธ๋กœ, ๊ถŒํˆฌ์—์„œ ๊ฐ€์žฅ ์ฒด์ค‘์ด ๊ฐ€๋ฒ„์šด ์ฒด๊ธ‰์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.Design Pattern์—์„œ๋Š” Object๋ฅผ ๊ฐ€๋ณ๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•œ ๊ฒƒ์˜ ์˜๋ฏธ์—์„œ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.Object๋Š” ์ปดํ“จํ„ฐ ๋‚ด๋ถ€์—์„œ ๊ฐ€์ƒ์ ์œผ๋กœ ์กด์žฌํ•˜๋Š” ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— ๋ฌด๊ฒ๋‹ค ๋˜๋Š” ๊ฐ€๋ณ๋‹ค๊ณ  ํ‘œํ˜„์€ ์‹ค์ œ ๋ฌด๊ฒŒ๊ฐ€ ์•„๋‹Œ, “๋ฉ”๋ชจ๋ฆฌ์˜ ์‚ฌ์šฉ๋Ÿ‰”์„ ์˜๋ฏธํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.๊ฐ์ฒด๋ฅผ ๋งŒ๋“ค ๋•Œ ๊ทธ ..

๐Ÿ—บ๏ธ Design Pattern

[Design Pattern] Bridge Pattern - ๋ธŒ๋ฆฟ์ง€ ํŒจํ„ด

Bridge Pattern๋ธŒ๋ฆฌ์ง€ ํŒจํ„ด(Bridge Pattern)์€ ์†Œํ”„ํŠธ์›จ์–ด ๋””์ž์ธ ํŒจํ„ด ์ค‘ ํ•˜๋‚˜๋กœ, ๊ตฌํ˜„๋ถ€์™€ ์ถ”์ƒํ™”๋œ ์ธํ„ฐํŽ˜์ด์Šค(๊ธฐ๋Šฅ) ๋ฅผ ๋ถ„๋ฆฌํ•˜์—ฌ ์„œ๋กœ ๋…๋ฆฝ์ ์œผ๋กœ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋Š” ํŒจํ„ด์ž…๋‹ˆ๋‹ค.์ด ํŒจํ„ด์€ ๊ตฌ์กฐ ํŒจํ„ด(Structural Pattern) ์ค‘ ํ•˜๋‚˜๋กœ, ์‹œ์Šคํ…œ์„ ๋” ๋ชจ๋“ˆํ™”ํ•˜๊ณ  ์œ ์ง€๋ณด์ˆ˜์„ฑ์„ ๋†’์ด๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.AbstractionHigh Level Layer์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ Interface ํ˜น์€ UIImplementor์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ๋Œ์•„๊ฐ€๋Š” ์‹ค์ œ ๊ตฌํ˜„ ์ฝ”๋“œAbstraction๋งŒ ๋ณผ ์ˆ˜ ์žˆ๊ณ  ์‹ค์ œ Implementor์€ ์ˆจ๊ธธ ์ˆ˜ ์žˆ๋Š” ๊ตฌ์กฐ์ž…๋‹ˆ๋‹ค.์™ธ๋ถ€์—์„œ ๋ณด์—ฌ์ง€๋Š” ๊ฒƒ๊ณผ ๋‚ด๋ถ€ Implementor๋ฅผ ๋ถ„๋ฆฌํ•˜๊ณ ์ž ํ•  ๋–„ ์‚ฌ์šฉํ•˜๊ธฐ ์ข‹์Šต๋‹ˆ๋‹ค.Bridege Pattern: Example 1Class..

๐Ÿ—บ๏ธ Design Pattern

[Design Pattern] Facade Pattern - ํŒŒ์‚ฌ๋“œ ํŒจํ„ด

Facade Patternํผ์‚ฌ๋“œ ํŒจํ„ด(Facade Pattern)์€ ๋ณต์žกํ•œ ์‹œ์Šคํ…œ์ด๋‚˜ ์„œ๋ธŒ์‹œ์Šคํ…œ์˜ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋‹จ์ˆœํ™”ํ•˜๋Š” ๋””์ž์ธ ํŒจํ„ด์ž…๋‹ˆ๋‹ค.์ด ํŒจํ„ด์€ ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์‹œ์Šคํ…œ์„ ๋” ์‰ฝ๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ์‹œ์Šคํ…œ์˜ ๋ณต์žก์„ฑ์„ ๊ฐ์ถ”๊ณ , ๋‹จ์ˆœํ•œ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.ํผ์‚ฌ๋“œ ํŒจํ„ด์€ ๊ฐ์ฒด์ง€ํ–ฅ ์„ค๊ณ„ ์›์น™ ์ค‘ ํ•˜๋‚˜์ธ "๋‹จ์ผ ์ฑ…์ž„ ์›์น™"(Single Responsibility Principle)์„ ๋”ฐ๋ฅด๋ฉฐ, ์‹œ์Šคํ…œ์˜ ๊ฐ ๊ตฌ์„ฑ ์š”์†Œ๋ฅผ ๋ณด๋‹ค ๋ช…ํ™•ํ•˜๊ฒŒ ๋ถ„๋ฆฌํ•ฉ๋‹ˆ๋‹ค.Facade Pattern์ด๋ž€ ๊ฑด๋ฌผ์˜ ์•ž๋ฉด์ฒ˜๋Ÿผ ๊ทธ ๋’ค์ชฝ์˜ ๋ณต์žกํ•จ์€ ๋‚ด๋ถ€์— ์ˆจ๊ธฐ๊ณ  ๋‹จ๋‹จํ•œ ์ธํ„ฐํŽ˜์ด์Šค๋งŒ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.์—ฌ๋Ÿฌ๊ฐœ์˜ ์„œ๋ธŒ์‹œ์Šคํ…œ์„ ํ†ตํ•ฉํ•˜์—ฌ ๊ณ ์ˆ˜์ค€์˜ API๋ฅผ ์ œ๊ณตํ•œ๋‹ค๋Š” ํŠน์ง•์ด ์žˆ์Šต๋‹ˆ๋‹ค.Client๋Š” ์—ฌ๋Ÿฌ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์™€ ํด๋ž˜์Šค๋ฅผ ํ•„์š”๋กœ ํ•˜๋Š” ์ƒํƒœ์ž…๋‹ˆ๋‹ค.์ด๋Ÿฐ ๊ฒฝ์šฐ, ์—ฌ๋Ÿฌ ํด๋ž˜..

๐Ÿ—บ๏ธ Design Pattern

[Design Pattern] Decorator Pattern - ๋ฐ์ฝ”๋ ˆ์ดํ„ฐ ํŒจํ„ด

Decorator Pattern๋ฐ์ฝ”๋ ˆ์ดํ„ฐ ํŒจํ„ด(Decorator Pattern)์€ ๊ฐ์ฒด์˜ ๊ธฐ๋Šฅ์„ ๋™์ ์œผ๋กœ ์ถ”๊ฐ€ํ•˜๊ณ  ํ™•์žฅํ•  ์ˆ˜ ์žˆ๋Š” ํŒจํ„ด์ž…๋‹ˆ๋‹ค.์ด ํŒจํ„ด์€ ์ƒ์†์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ ๋„ ๊ฐ์ฒด์— ์ƒˆ๋กœ์šด ํ–‰๋™์„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ค๋‹ˆ๋‹ค.๋ฐ์ฝ”๋ ˆ์ดํ„ฐ ํŒจํ„ด์€ ์—ฌ๋Ÿฌ ๊ฐœ์˜ ๋ฐ์ฝ”๋ ˆ์ดํ„ฐ ๊ฐ์ฒด๋ฅผ ์กฐํ•ฉํ•˜์—ฌ ๋‹ค์–‘ํ•œ ๊ธฐ๋Šฅ์„ ๋™์ ์œผ๋กœ ์กฐํ•ฉํ•  ์ˆ˜ ์žˆ๋Š” ์œ ์—ฐ์„ฑ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.Decorator Pattern์€ Object(๊ฐ์ฒด)๋ฅผ ๊พธ๋ฉฐ์ฃผ๋Š” ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค.์›ํ•˜๋Š” ๊ธฐ๋Šฅ์œผ๋กœ ๊ฐ์‹ธ์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋งŒ๋“ค์–ด์ฃผ๋Š” ํŒจํ„ด ์ž…๋‹ˆ๋‹ค.class Animal: def speak(self): passclass Cat(Animal): def speak(self): print("Meow", end='')class Dog(Animal): ..

๐Ÿ—บ๏ธ Design Pattern

[Design Pattern] Adapter Pattern - ์–ด๋Œ‘ํ„ฐ ํŒจํ„ด

Adapter Pattern - ์–ด๋Œ‘ํ„ฐ ํŒจํ„ดAdapter Pattern์€ ํ˜ธํ™˜๋˜์ง€ ์•Š๋Š” ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๊ฐ€์ง„ ํด๋ž˜์Šค๋“ค์ด ํ•จ๊ป˜ ๋™์ž‘ํ•  ์ˆ˜ ์žˆ๋„๋ก ์ค‘๊ฐ„์— ์–ด๋Œ‘ํ„ฐ๋ฅผ ๋‘์–ด ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋ณ€ํ™˜ํ•ด์ฃผ๋Š” ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค.ํ•˜๋‚˜์˜ Interface๋ฅผ ๋‹ค๋ฅธ Interface๋กœ ์ „ํ™˜ํ•˜๋Š” ์—ญํ•  → ์ด๋Ÿฌํ•œ ์—ญํ• ์„ Adapter Pattern์— ์ ์šฉํ•ฉ๋‹ˆ๋‹ค.‘์ด๋ฏธ ์ œ๊ณต๋˜์–ด ์žˆ๋Š” ๊ฒƒ’๊ณผ ‘ํ•„์š”ํ•œ ๊ฒƒ’ ์‚ฌ์ด์˜ ‘์ฐจ์ด’๋ฅผ ์—†์• ์ฃผ๋Š” ๋””์ž์ธ ํŒจํ„ด์„ Adapter ํŒจํ„ด์ด๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค.๋˜ํ•œ Adapter ํŒจํ„ด์€ Wrapper ํŒจํ„ด์œผ๋กœ ๋ถˆ๋ฆฌ๊ธฐ๋„ ํ•ฉ๋‹ˆ๋‹ค.Wrapper๋Š” ‘๊ฐ์‹ธ๋Š” ๊ฒƒ’์ด๋ผ๋Š” ์˜๋ฏธ๊ฐ€ ์žˆ๋Š”๋ฐ, ๋ฌด์–ธ๊ฐ€๋ฅผ ํฌ์žฅํ•ด์„œ ๋‹ค๋ฅธ ์šฉ๋„๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๊ฒŒ ๊ตํ™˜ํ•ด์ฃผ๋Š” ๊ฒƒ์ด wrapper์ด๋ฉฐ, adapter๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค.๋‘๊ฐ€์ง€์˜ ์ข…๋ฅ˜๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.ํด๋ž˜์Šค์— ์˜ํ•œ Adap..

๐Ÿ—บ๏ธ Design Pattern

[Design Pattern] Proxy Pattern - ํ”„๋ก์‹œ ํŒจํ„ด

Proxy Pattern - ํ”„๋ก์‹œ ํŒจํ„ดProxy Pattern์€ ์ฃผ๋กœ ๊ฐ์ฒด์˜ ์ ‘๊ทผ์„ ์ œ์–ดํ•˜๊ฑฐ๋‚˜ ๊ฐ์ฒด์— ์ถ”๊ฐ€์ ์ธ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.์ด ํŒจํ„ด์€ ์ฃผ์ฒด(Real Subject)์™€ ๊ทธ ์ฃผ์ฒด์— ๋Œ€ํ•œ ๋Œ€๋ฆฌ์ž(Proxy)๋กœ ๊ตฌ์„ฑ๋ฉ๋‹ˆ๋‹ค.Proxy๋Š” ๋Œ€๋ฆฌ์ธ ์ด๋ผ๋Š” ์˜๋ฏธ, ์ผ์„ ๋Œ€์‹  ํ•˜๋Š” ์‚ฌ๋žŒ์ด๋ผ๋Š” ์˜๋ฏธ์ž…๋‹ˆ๋‹ค.‘๋Œ€๋ฆฌ์ธ proxy’์ด ํ•  ์ˆ˜ ์žˆ๋Š” ๋ฒ”์œ„๋ฅผ ๋„˜๋Š” ์ผ์ด ๋ฐœํ–‰ํ•˜๋ฉด, ์‹ค์ œ ‘๋ณธ์ธ real’ ์—๊ฒŒ ์™€์„œ ์—…๋ฌด์š”์ฒญ์„ ํ•œ๋‹ค๋Š” ํŠน์ง•์ด ์žˆ์Šต๋‹ˆ๋‹ค.๊ฐ์ฒด์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์—์„œ๋Š” ๋ฐ”๋น ์„œ ์ผ์„ ํ•  ์ˆ˜ ์—†๋Š” ‘real object’ ๋Œ€์‹ ์— ‘proxy object’๊ฐ€ ์–ด๋Š์ •๋„ ์ผ์„ ์ฒ˜๋ฆฌํ•˜๊ธฐ๋„ ํ•ฉ๋‹ˆ๋‹ค.๊ทธ๋ฆฌ๊ณ  real ์˜ค๋ธŒ์ ํŠธ๋Š” proxy ์˜ค๋ธŒ์ ํŠธ์˜ ์กด์žฌ๋ฅผ ๋ชจ๋ฆ…๋‹ˆ๋‹ค.์ฆ‰, ์ด๋ง์€ ์ž์‹ ์ด proxy๋ฅผ ๊ฒฝ์œ ํ•ด์„œ ํ˜ธ์ถœ๋˜๊ณ  ์žˆ๋Š”์ง€ ์ง์ ‘ ํ˜ธ..

๐Ÿ—บ๏ธ Design Pattern

[Design Pattern] Singleton Pattern - ์‹ฑ๊ธ€ํ†ค ํŒจํ„ด & Metaclass

Singleton PatternSingleton ํŒจํ„ด์€ ํด๋ž˜์Šค์˜ ์ธ์Šคํ„ด์Šค๊ฐ€ ํ•˜๋‚˜๋งŒ ์ƒ์„ฑ๋˜๋„๋ก ๋ณด์žฅํ•˜๊ณ , ๊ทธ ์ธ์Šคํ„ด์Šค์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋Š” ์ „์—ญ ์ ‘๊ทผ์ ์„ ์ œ๊ณตํ•˜๋Š” ํŒจํ„ด์ž…๋‹ˆ๋‹ค.๊ทธ๋ฆฌ๊ณ  ํŠน์ • ํด๋ž˜์Šค์˜ ์ธ์Šคํ„ด์Šค๊ฐ€ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ „์ฒด์—์„œ ํ•˜๋‚˜๋งŒ ์กด์žฌํ•ด์•ผ ํ•  ๋•Œ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.๋˜ํ•œ ํŠน์ง•๋“ค์„ ์•„๋ž˜์— ์ ์–ด๋ณด์ž๋ฉด.ํด๋ž˜์Šค์— ๋Œ€ํ•œ ๋‹จ์ผ ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.์ „์—ญ ๊ฐ์ฒด๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.๊ณต์œ ๋œ ๋ฆฌ์†Œ์Šค์— ๋Œ€ํ•œ ๋™์‹œ ์ ‘๊ทผ ์ œ์–ด๊ฐ€ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.๊ธ€๋กœ๋ฒŒ ์—‘์„ธ์Šค ์ง€์ ์„ ์ œ๊ณตํ•˜๋Š”, ๋‹จ์ ์ด ๊ฑฐ์ด ์—†๋Š” ๊ฒ€์ฆ๋œ ํŒจํ„ด์ž…๋‹ˆ๋‹ค.์œ„์˜ ๋‹ค์ด์–ด๊ทธ๋žจ์„ ์˜ˆ์‹œ๋กœ ๋ณด๋ฉด, ์ƒ์„ฑ์ž๋ฅผ private๋กœ ์„ ์–ธํ•˜๊ณ , ๊ฐ์ฒด๋ฅผ ์ดˆ๊ธฐํ™” ํ•˜๋Š” static ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“ค์–ด ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.์ฒซ ํ˜ธ์ถœ์— ๊ฐ์ฒด๊ฐ€ ์ƒ์„ฑ๋˜๊ณ , ๊ทธํ›„ ํด๋ž˜์Šค๋Š” ๋™์ผํ•œ ๊ฐ์ฒด๋ฅผ ๊ณ„์† ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.class Singleton(objec..

๐Ÿ—บ๏ธ Design Pattern

[Design Pattern] Builder Pattern - ๋นŒ๋” ํŒจํ„ด

Builder PatternBuilder ํŒจํ„ด์€ ๊ฐ์ฒด ์ƒ์„ฑ ํŒจํ„ด ์ค‘ ํ•˜๋‚˜๋กœ, ๋ณต์žกํ•œ ๊ฐ์ฒด๋ฅผ ๋‹จ๊ณ„์ ์œผ๋กœ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋Š” ํŒจํ„ด์ž…๋‹ˆ๋‹ค.Object์˜ ์ƒ์„ฑ๊ณผ์ •์ด ๋ณต์žกํ•  ๋•Œ ์ด๋ฅผ ๊ฐ„๋‹จํ•˜๊ฒŒ ๋งŒ๋“ค์–ด์ค๋‹ˆ๋‹ค.์ƒ์„ฑ๊ณผ์ •์ด ๋ณต์žกํ•  ์ˆ˜ ์žˆ๋Š” ์—ฌ๋Ÿฌ ๊ฒฝ์šฐ๋Š” ๋งค์šฐ ๋‹ค์–‘ํ•ฉ๋‹ˆ๋‹ค.์˜ˆ๋ฅผ ๋“ค์–ด ํ•˜๋‚˜์˜ Object๋ฅผ ์ƒ์„ฑ์‹œ, ์—ฌ๋Ÿฌ๊ฐœ์˜ argument๊ฐ€ ํ•„์š”ํ•  ๋•Œ Builder Pattern์ด ์‰ฝ๊ฒŒ ๋งŒ๋“ค์–ด ์ค„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.ํ•ต์‹ฌ ๊ฐœ๋…Builder ์ธํ„ฐํŽ˜์ด์Šค: ๊ฐ์ฒด๋ฅผ ๊ตฌ์„ฑํ•˜๋Š” ๊ฐ ๋‹จ๊ณ„๋ฅผ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.Concrete Builder ํด๋ž˜์Šค: Builder ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๊ตฌํ˜„ํ•˜์—ฌ, ๊ฐ ๋‹จ๊ณ„๋ฅผ ๊ตฌ์ฒด์ ์œผ๋กœ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.Director: Builder ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ์ฒด ์ƒ์„ฑ์˜ ์ˆœ์„œ๋ฅผ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค. ์ƒ์„ฑ ๊ณผ์ •์˜ ์ œ์–ด๋ฅผ ๋‹ด๋‹นํ•ฉ๋‹ˆ๋‹ค.Product: ์ตœ์ข…์ ..

๐Ÿ—บ๏ธ Design Pattern

[Design Pattern] Prototype Pattern - ํ”„๋กœํ† ํƒ€์ž… ํŒจํ„ด

Prototype Pattern๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•  ๋•Œ ๋ฏธ๋ฆฌ ์ •์˜๋œ ๋‹ค๋ฅธ ๊ฐ์ฒด๋ฅผ ๋ณต์ œ(clone)ํ•˜์—ฌ ์ƒˆ๋กœ์šด ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค์•„๋ž˜์˜ ๊ฒฝ์šฐ ํด๋ž˜์Šค๋กœ๋ถ€ํ„ฐ ์ธ์Šคํ„ด์Šค๋ฅผ ๋งŒ๋“œ๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ ์ธ์Šคํ„ด์Šค๋ฅผ ๋ณต์‚ฌํ•ด์„œ ์ƒˆ๋กœ์šด ์ธ์Šคํ„ด์Šค๋ฅผ ๋งŒ๋“œ๋Š”๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.์ข…๋ฅ˜๊ฐ€ ๋„ˆ๋ฌด ๋งŽ์•„์„œ ํด๋ž˜์Šค๋กœ ์ •๋ฆฌ๋˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐํด๋ž˜์Šค๋กœ๋ถ€ํ„ฐ ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ์ด ์–ด๋ ค์šด ๊ฒฝ์šฐframework ์™€ ์ƒ์„ฑํ•˜๋Š” ์ธ์Šคํ„ด์Šค๋ฅผ ๋ถ„๋ฆฌํ•˜๊ณ  ์‹ถ์€ ๊ฒฝ์šฐ์žฅ์ ๊ฐ์ฒด ์ƒ์„ฑ ๋น„์šฉ ์ ˆ๊ฐ: ๋ณต์ œ(clone) ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜๋ฏ€๋กœ, ๊ฐ์ฒด๋ฅผ ์ฒ˜์Œ๋ถ€ํ„ฐ ์ƒ์„ฑํ•˜๋Š” ๊ฒƒ๋ณด๋‹ค ๋น„์šฉ์ด ์ ๊ฒŒ ๋“ญ๋‹ˆ๋‹ค.๊ฐ์ฒด ์ดˆ๊ธฐํ™”์˜ ๋‹จ์ˆœํ™”: ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ์ดˆ๊ธฐํ™”ํ•˜๋Š” ๊ณผ์ •์ด ๋ณต์žกํ•  ๊ฒฝ์šฐ, ๋ฏธ๋ฆฌ ์ดˆ๊ธฐํ™”๋œ ๊ฐ์ฒด๋ฅผ ๋ณต์ œํ•˜์—ฌ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.๋™์ ์ธ ๊ฐ์ฒด ์ƒ์„ฑ: ๋Ÿฐํƒ€์ž„์— ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹จ์ ๊นŠ..

๐Ÿ—บ๏ธ Design Pattern

[Design Pattern] Abstract Factory Pattern - ์ถ”์ƒ ํŒฉํ† ๋ฆฌ ํŒจํ„ด

Abstract Factory Pattern ์ถ”์ƒ ํŒฉํ† ๋ฆฌ ํŒจํ„ด(Abstract Factory Pattern)์€ ๊ด€๋ จ์„ฑ์ด ์žˆ๋Š” ์—ฌ๋Ÿฌ ์ข…๋ฅ˜์˜ ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜๊ธฐ ์œ„ํ•œ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์ œ๊ณตํ•˜๋Š” ์ƒ์„ฑ ๋””์ž์ธ ํŒจํ„ด์ž…๋‹ˆ๋‹ค. ์ด ํŒจํ„ด์€ ๊ตฌ์ฒด์ ์ธ ํด๋ž˜์Šค์— ๋Œ€ํ•œ ์ •๋ณด ์—†์ด๋„ ์„œ๋กœ ์—ฐ๊ด€๋˜๊ฑฐ๋‚˜ ์˜์กด์ ์ธ ๊ฐ์ฒด์˜ ๊ตฐ์„ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ด์ค๋‹ˆ๋‹ค. ๋˜ํ•œ, ํŒฉํ† ๋ฆฌ ์ž์ฒด๋ฅผ ์ถ”์ƒํ™”ํ•จ์œผ๋กœ์จ ๊ฐ์ฒด๋“ค์„ ์‰ฝ๊ฒŒ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฃผ์š” ํŠน์ง•์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค: ์ธํ„ฐํŽ˜์ด์Šค ์ œ๊ณต: ์ถ”์ƒ ํŒฉํ† ๋ฆฌ๋Š” ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜๊ธฐ ์œ„ํ•œ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์ด ์ธํ„ฐํŽ˜์ด์Šค๋Š” ๊ด€๋ จ๋œ ๊ฐ์ฒด๋“ค์˜ ์ƒ์„ฑ์„ ์ถ”์ƒํ™”ํ•˜๊ณ , ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ๋Š” ๊ฐ์ฒด์˜ ๊ตฌ์ฒด์ ์ธ ํด๋ž˜์Šค์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ์ˆจ๊น๋‹ˆ๋‹ค. ์„œ๋กœ ์—ฐ๊ด€๋œ ๊ฐ์ฒด ์ƒ์„ฑ: ์ถ”์ƒ ํŒฉํ† ๋ฆฌ ํŒจํ„ด์€ ์„œ๋กœ ์—ฐ๊ด€๋œ ๊ฐ์ฒด๋“ค์˜ ๊ตฐ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ..

Bigbread1129
'๐Ÿ—บ๏ธ Design Pattern' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (2 Page)