Design_Pattern - 8BitsCoding/RobotMentor GitHub Wiki
Solid Design Principles
Gamma Categorization
Creational Patterns
Deal with the creation (construction) of objects
Builder Pattern - 1
Builder Pattern - 2 : ์ฌ ์ ๋ฆฌ
ํด๋น ์ค๋ธ์ ํธ ์์ฑ์ ํ์ํ ์์ฑ์ ๋จ๊ณ๋ฅผ ์๋
ํด๋์ค์๊ฒ ๋๊ธฐ๋ ํํ
Some objects are simple and can be created in a single constructor call
When piecewise(์กฐ๊ฐ์กฐ๊ฐ) object contruction is complicated provice an API for doing it succinctly(๊ฐ๊ฒฐํ๊ฒ)
Abstract Factory Pattern
(Abstract) Factory Pattern - 2 : ์ฌ ์ ๋ฆฌ
๊ด๋ จ์๋ ๊ฐ์ฒด์ ์์ฑ์ ๊ฐ์ํ ํ๋ค.
A component(๊ตฌ์ฑ ์์) responsible(์ฑ
์) solely(๋ค๋ง) for the wholesale(๋ชจ์กฐ๋ฆฌ)(not piecewise) creation of objects.
์ฌ๊ธฐ์ Builder์ ์ฐจ์ด์ ์ด Factory์ ๊ฒฝ์ฐ wholesale์ด๊ณ Builder๋ piecewise์ด๋ผ๋ ์ .
Prototype Pattern
Prototype Pattern - 2 : ์ฌ ์ ๋ฆฌ
์์ฐ ๋น์ฉ(๋ฉ๋ชจ๋ฆฌ)๊ฐ ๋์ ์ค๋ธ์ ํธ์ ๋ณต์ฌ ๋ฐฉ๋ฒ
When it's easier to copy an existing object to fully initialize a new one.
Complicated object(e.g. cars) aren't designed from scratch(๊ฐ์ถ์ด์ง)
We make a copy(clone) the prototype and customize it
A partially or fully initialized object that you copy(clone) and make use of.
SingleTon Pattern
SingleTon Pattern - 2 : ์ฌ ์ ๋ฆฌ
๋จ ํ๋์ ๊ฐ์ฒด๋ฅผ ์์ฑํ๊ณ ์ถ์ ๋
For some components it only makes sense(์ดํดํ๋ค) to have one in the system.
Want to prevent anyone creating additional copies
Structural Patterns
Concerned with the structure (e.g. class members)
Many patterns are wrappers that mimic the underlying class' interface
์ค๋ธ์ ํธ ํจ์์ ๊ตฌํ๋ถ์ ์ฌ์ฉ๋ถ๋ฅผ ๋๋์ด ์ฐ๊ณ ์ถ์ ๋
Connecting components together through abstractions.
A mechanism that decouples(๋ถ๋ฆฌ) an interface(hierarchy) from an implementation.
Treating(์น๋ฃ) individual and aggregate(๊ณจ์ฌ) object uniformly(๊ท ์ผํ๊ฒ).
Objects use other objects' fields/properties/members through inheritance and composition
Composition lets us make compound(ํํฉ๋ฌผ) objects
Composite design pattern is used to treat both single(scalar) and composite objects uniformly
Behavioral Patterns
They are all different; no central theme
๋์ ์ผ๋ก ๋ฉ๋ชจ๋ฆฌ๋ฅผ ํ ๋นํ๋ฉฐ ๊ธฐ๋ฅ์ ์ถ๊ฐํ ์ ์ฌ์ฉํ๋ค.
Adding behavior without altering(๋ณ๊ฒฝ) the class itself.
Do not want to rewrite or alter existing code
ํจํด์ด๋ผ ํ๊ธฐ ํ๋ฆ, ์ผ๋ฐ์ ์ผ๋ก OOPํํ์ด๋ค.
Exposing several components through a single interface
๋ฐ์ดํฐ๋ฅผ ๊ณต์ ์ฌ์ฉํ์ฌ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ ์ฝํ ์ ์๋ ํจํด ๋ง์ด ์ฌ์ฉ๋จ.
๊ฒฐ๊ตญ์ map๊ณผ ๊ฐ์ ์ปจํ
์ด๋๋ฅผ ํตํด์ ๋ฐ์ดํฐ ๊ด๋ฆฌํ๋ ํจํด์ด๋ค.
Space optimization
Avoid redundancy when storing data.
A space optimization technique that lets us use less memory by storing externally the data associated with similar objects
๋๋ฆฌ์๋ก์จ ์ผ์ ๋งก๊ธฐ๋ฉด ๊ทธ ์ผ์ ์ฒ๋ฆฌํ๊ณ ์๋ฃ๋๋ฉด ๊ทธ ๊ฒฐ๊ณผ๋ฅผ ์๋ ค์ฃผ๋ ํจํด
An interface for accessing a particular resource.
You are calling foo.bar() -> This assumes that foo is in the same process as bar() -> What if, later on, you want to put all Foo-related operations into a separate process
Can you avoid changing yout code? -> Proxy to the rescue!
์๊ณ ๋ฆฌ์ฆ์ ์ฒ๋ฆฌํ ์ ์๋ ๊ธฐํ๋ฅผ ์ฒด์ธ์ฒ๋ผ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ํ ๋นํ๋ฉฐ ๋ถ์ฌ
Sequence of handlers processing an event one after another
์๊ณ ๋ฆฌ์ฆ์ ๊ฐ์ฒด์ ํํ๋ก ์บก์ํํ๋ ๋ชฉ์ ์ ํจํด
๊ฐ์ฒด์ ์ถ์์ ์ ๊ทผ ๊ฐ์ฒด๋ฅผ ๋ง๋ค๊ณ ๋ง๋ ์ถ์์ ๊ฐ์ฒด๋ฅผ ๋ฐ๊ฟ๊ฐ๋ฉด์ ์ฐ๊ณ ์ถ์ ๋
System behavior partially specified at runtime.
์๊ณ ๋ฆฌ์ฆ์ ๊ตฌ์กฐ๋ฅผ ์ ์ ํ๊ณ ์ ์ํ ์๋
ํด๋์ค์์ ๊ตฌํํ๋ ์ผ๋ฐ์ ํํ
A high-level blueprint for an algorithm to be completed by inheritors.
์ผ์ข
์ Parser๋ผ ์๊ฐํด๋ ์ข๋ค.
๊ฐ์ฅํจ์จ์ ์ธ Parser๋ง๋ค๊ธฐ ๊ฐ์ข!
์ปจํ
์ด๋์ Iterator๋ฅผ ์ด๋ป๊ฒ ๋ง๋๋์ง์ ๊ดํ ๋ด์ฉ.
How traversal of data structores happens and who makes it happen.
object์ ์ํ๋ฅผ undoํ๊ฒ ํด์ค๋ค.
A
B
Builder Pattern : ํด๋น ์ค๋ธ์ ํธ ์์ฑ์ ํ์ํ ์์ฑ์ ๋จ๊ณ๋ฅผ ์๋
ํด๋์ค์๊ฒ ๋๊ธฐ๋ ํํ
Bridge Pattern : ์ค๋ธ์ ํธ ํจ์์ ๊ตฌํ๋ถ์ ์ฌ์ฉ๋ถ๋ฅผ ๋๋์ด ์ฐ๊ณ ์ถ์ ๋
C
D
Decorator Pattern : ๋์ ์ผ๋ก ๋ฉ๋ชจ๋ฆฌ๋ฅผ ํ ๋นํ๋ฉฐ ๊ธฐ๋ฅ์ ์ถ๊ฐํ ์ ์ฌ์ฉํ๋ค.
F
Facade Pattern : ํจํด์ด๋ผ ํ๊ธฐ ํ๋ฆ, ์ผ๋ฐ์ ์ผ๋ก OOPํํ์ด๋ค.
Flyweight Pattern : ๋ฐ์ดํฐ๋ฅผ ๊ณต์ ์ฌ์ฉํ์ฌ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ ์ฝํ ์ ์๋ ํจํด ๋ง์ด ์ฌ์ฉ๋จ.
M
O
Observer Pattern : ๋ฑ๋ก๋ ๊ฐ ๊ฐ์ฒด๋ก ์๊ณ ๋ฆฌ์ฆ์ด๋ ๋ฐ์ดํฐ๋ฅผ ๋ธ๋ก๋ ์บ์คํธํ๊ณ ์ถ์๋ ์ฌ์ฉ๋๋ค.
P
Prototype Pattern : ์์ฐ ๋น์ฉ(๋ฉ๋ชจ๋ฆฌ)๊ฐ ๋์ ์ค๋ธ์ ํธ์ ๋ณต์ฌ ๋ฐฉ๋ฒ
Proxy Pattern : ๋๋ฆฌ์๋ก์จ ์ผ์ ๋งก๊ธฐ๋ฉด ๊ทธ ์ผ์ ์ฒ๋ฆฌํ๊ณ ์๋ฃ๋๋ฉด ๊ทธ ๊ฒฐ๊ณผ๋ฅผ ์๋ ค์ฃผ๋ ํจํด
S
SingleTon Pattern : ๋จ ํ๋์ ๊ฐ์ฒด๋ฅผ ์์ฑํ๊ณ ์ถ์ ๋
Strategy Pattern : ๊ฐ์ฒด์ ์ถ์์ ์ ๊ทผ ๊ฐ์ฒด๋ฅผ ๋ง๋ค๊ณ ๋ง๋ ์ถ์์ ๊ฐ์ฒด๋ฅผ ๋ฐ๊ฟ๊ฐ๋ฉด์ ์ฐ๊ณ ์ถ์ ๋
State Pattern : ๋์ ์ผ๋ก ํ๋(์๊ณ ๋ฆฌ์ฆ)์ ๊ต์ฒดํด์ ์ฌ์ฉํ ์ ์๋ค.
T
Template Method Pattern : ์๊ณ ๋ฆฌ์ฆ์ ๊ตฌ์กฐ๋ฅผ ์ ์ ํ๊ณ ์ ์ํ ์๋
ํด๋์ค์์ ๊ตฌํํ๋ ์ผ๋ฐ์ ํํ
V
Visitor Pattern : ํน์ ๊ฐ์ฒด์์ ๊ด๋ฆฌํ๋ ์ค๋ธ์ ํธ์ ๋ฐ์ดํฐ์ ์๊ณ ๋ฆฌ์ฆ์ ๋ฐ๊ฟ๊ฐ๋ฉฐ ์ ๊ทผํ๊ณ ์ถ์ ๋
๐๏ธ Page Index for this GitHub Wiki