# [Design Pattern] ๊ฐœ์š”



์ผ์ข…์˜ ์„ค๊ณ„ ๊ธฐ๋ฒ•์ด๋ฉฐ, ์„ค๊ณ„ ๋ฐฉ๋ฒ•์ด๋‹ค.

  • # ๋ชฉ์ 

    SW ์žฌ์‚ฌ์šฉ์„ฑ, ํ˜ธํ™˜์„ฑ, ์œ ์ง€ ๋ณด์ˆ˜์„ฑ์„ ๋ณด์žฅ.


  • # ํŠน์ง•

    ๋””์ž์ธ ํŒจํ„ด์€ ์•„์ด๋””์–ด์ž„, ํŠน์ •ํ•œ ๊ตฌํ˜„์ด ์•„๋‹˜.

    ํ”„๋กœ์ ํŠธ์— ํ•ญ์ƒ ์ ์šฉํ•ด์•ผ ํ•˜๋Š” ๊ฒƒ์€ ์•„๋‹ˆ์ง€๋งŒ, ์ถ”ํ›„ ์žฌ์‚ฌ์šฉ, ํ˜ธํ™˜, ์œ ์ง€ ๋ณด์ˆ˜์‹œ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ ํ•ด๊ฒฐ์„ ์˜ˆ๋ฐฉํ•˜๊ธฐ ์œ„ํ•ด ํŒจํ„ด์„ ๋งŒ๋“ค์–ด ๋‘” ๊ฒƒ์ž„.


  • # ์›์น™ - SOLID (๊ฐ์ฒด์ง€ํ–ฅ ์„ค๊ณ„ ์›์น™)

    (๊ฐ„๋žตํ•œ ์„ค๋ช…)

    1. # Single Responsibility Principle

      ํ•˜๋‚˜์˜ ํด๋ž˜์Šค๋Š” ํ•˜๋‚˜์˜ ์—ญํ• ๋งŒ ํ•ด์•ผ ํ•จ.

    2. # Open - Close Principle

      ํ™•์žฅ (์ƒ์†)์—๋Š” ์—ด๋ ค์žˆ๊ณ , ์ˆ˜์ •์—๋Š” ๋‹ซํ˜€ ์žˆ์–ด์•ผ ํ•จ.

    3. # Liskov Substitution Principle

      ์ž์‹์ด ๋ถ€๋ชจ์˜ ์ž๋ฆฌ์— ํ•ญ์ƒ ๊ต์ฒด๋  ์ˆ˜ ์žˆ์–ด์•ผ ํ•จ.

    4. # Interface Segregation Principle

      ์ธํ„ฐํŽ˜์ด์Šค๊ฐ€ ์ž˜ ๋ถ„๋ฆฌ๋˜์–ด์„œ, ํด๋ž˜์Šค๊ฐ€ ๊ผญ ํ•„์š”ํ•œ ์ธํ„ฐํŽ˜์ด์Šค๋งŒ ๊ตฌํ˜„ํ•˜๋„๋ก ํ•ด์•ผํ•จ.

    5. # Dependency Inversion Property

      ์ƒ์œ„ ๋ชจ๋“ˆ์ด ํ•˜์œ„ ๋ชจ๋“ˆ์— ์˜์กดํ•˜๋ฉด ์•ˆ๋จ.

      ๋‘˜ ๋‹ค ์ถ”์ƒํ™”์— ์˜์กดํ•˜๋ฉฐ, ์ถ”์ƒํ™”๋Š” ์„ธ๋ถ€ ์‚ฌํ•ญ์— ์˜์กดํ•˜๋ฉด ์•ˆ๋จ.


  • # ๋ถ„๋ฅ˜ (์ค‘์š”)

3๊ฐ€์ง€ ํŒจํ„ด์˜ ๋ชฉ์ ์„ ์ดํ•ดํ•˜๊ธฐ!

  1. # ์ƒ์„ฑ ํŒจํ„ด (Creational) : ๊ฐ์ฒด์˜ ์ƒ์„ฑ ๋ฐฉ์‹ ๊ฒฐ์ •

    Class-creational patterns, Object-creational patterns.

    ์˜ˆ) DBConnection์„ ๊ด€๋ฆฌํ•˜๋Š” Instance๋ฅผ ํ•˜๋‚˜๋งŒ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋„๋ก ์ œํ•œํ•˜์—ฌ, ๋ถˆํ•„์š”ํ•œ ์—ฐ๊ฒฐ์„ ๋ง‰์Œ.
    

  2. # ๊ตฌ์กฐ ํŒจํ„ด (Structural) : ๊ฐ์ฒด๊ฐ„์˜ ๊ด€๊ณ„๋ฅผ ์กฐ์ง

    ์˜ˆ) 2๊ฐœ์˜ ์ธํ„ฐํŽ˜์ด์Šค๊ฐ€ ์„œ๋กœ ํ˜ธํ™˜์ด ๋˜์ง€ ์•Š์„ ๋•Œ, ๋‘˜์„ ์—ฐ๊ฒฐํ•ด์ฃผ๊ธฐ ์œ„ํ•ด์„œ ์ƒˆ๋กœ์šด ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค์–ด์„œ ์—ฐ๊ฒฐ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋„๋ก ํ•จ.
    

  3. # ํ–‰์œ„ ํŒจํ„ด (Behavioral): ๊ฐ์ฒด์˜ ํ–‰์œ„๋ฅผ ์กฐ์ง, ๊ด€๋ฆฌ, ์—ฐํ•ฉ

    ์˜ˆ) ํ•˜์œ„ ํด๋ž˜์Šค์—์„œ ๊ตฌํ˜„ํ•ด์•ผ ํ•˜๋Š” ํ•จ์ˆ˜ ๋ฐ ์•Œ๊ณ ๋ฆฌ์ฆ˜๋“ค์„ ๋ฏธ๋ฆฌ ์„ ์–ธํ•˜์—ฌ, ์ƒ์†์‹œ ์ด๋ฅผ ํ•„์ˆ˜๋กœ ๊ตฌํ˜„ํ•˜๋„๋ก ํ•จ.
    

์ตœ์ข… ์ˆ˜์ • : 12/17/2022, 7:23:59 AM