Chapter 4 ¶
Structural Patterns ¶
Adapter(105) Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces
Bridge(121) Decouple an abstraction from its implementation so that the two can vary independently
Composite(137) Compose objects into tree structrures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.
Decorator(161) Attach Additional responsibilities and behavior to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.
Facade(179) Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.
Flyweight(189) Use sharing to support large numbers of fine-grained objects efficiently.
Proxy(213) Provide a surrogate or placeholder for another object to control access to it.
Adapter(105) ๋ ๋ค๋ฅธ ์ธํฐํ์ด์ค์ Clients๋ค์ด ์์ํ ์ ์๋ ํํ์ค ํด๋์ค์ ์ธํฐํ์ด์ค๋ฅผ ๋ณํ์ํจ๋ค. ์ฆ, Adapter๋ ์๋ฆฝํ ์ ์๋ ๋ค๋ฅธ ์ํฉ์ ๋๊ฐ์ง์ ์ผ์ ์ํํ๋ ํด๋์ค๋ฅผ ์ํธ๊ฐ์ฐ๊ฒฐ์ํค๋ ์ญํ ์ ํ๋ค.
Bridge(121)์ ์ ์ฉ(implementation)์ ์ถ์ํ๋ฅผ ํตํ ๋ถ๋ฆฌ๋ฅผ ํตํ์ฌ ๋์๊ฒ ๋
๋ฆฝ์ฑ์ ๋ถ์ฌํ๋ค.
Composite(137)์ ์ ์ฒด-๋ถ๋ถ์ ๊ณ์ธต ๋ํ๋ด๊ธฐ์ํ tree๊ตฌ์กฐ๋ก ๊ฐ object๋ฅผ ๊ตฌ์ฑ์ํจ๋ค. Composite๋ client ๋ค์ด ๊ฐ๋ณ์ object์ object๋ค์ ์กฐํฉ์ ์ผ์ ํ ๊ท์น์ผ๋ก ๋ค๋ฃฐ์ ์๊ฒ ํ๋ค.
Decorator(161)์ object์๊ฒ ๋์ ์ผ๋ก ์๋ฌด์ ํ ์ผ์ ๋ถ์ฌํ๋ค. Decorator๋ ๊ธฐ๋ฅ์ ํ์ฅ์ ์ํ ํจ์์ ๋ํ์ฌ ์ ์ฐํ ์ ํ์ ์ ๊ณตํ๋ค.
Facade(179)๋ ํ์ฅ๋ ์์คํ
์์(ํ์, ์์๋ฐ์) interface๋ค์ ์กฐํฉ์ ๋ํ ์ผ๊ด์ ์ธ ์ ๊ทผ(interface)์ ์ ๊ณตํ๋ค. Facade๋ ํ์ฅ ์์คํ
(ํ์, ์์๋ฐ์)์ ์ข๋ ์ฌ์ฉํ๊ฒ ์ฝ๋๋ก ๋์ ๋จ๊ณ์ interface๋ฅผ ์ ์ํ๋ค.
Flyweight(189)๋ ๋ง์ ์์ ์ ๋ง๋ค์ด์ง object๋ค์ ํจ๊ณผ์ ์ธ ๊ณต์ ๋ฅผ ๊ฐ๋ฅ์ผ ํ๋ค.
Proxy(213)์ ๋ค๋ฅธ object์ ์กฐ์ ,๊ด๋ฆฌ(control)์ ์ํ ๋ํ์, placeholer๋ฅผ ์ ๊ณตํ๋ค.