结构模式 处理 对象和类如何被组合 成更大的结构 — 组织实体之间的关系以形成灵活、高效的结构。它们包括 Adapter、Decorator、Facade、Proxy、Composite 和 Bridge。
结构模式解决什么
STRUCTURAL patterns concern how objects/classes are COMPOSED/related:
→ organize relationships to build larger structures from objects
→ make components work together flexibly; simplify complex structures
→ about COMPOSITION and structure, not creation or behavior
主要的结构模式
ADAPTER → make incompatible interfaces work together (wrap to convert one interface to
another) — "a translator"
DECORATOR → add behavior by wrapping objects (covered separately)
FACADE → provide a SIMPLE interface to a complex subsystem (hide complexity behind one
clean interface)
PROXY → a placeholder/surrogate controlling access to another object (lazy loading,
access control, caching, remote)
COMPOSITE → treat individual objects and groups of objects UNIFORMLY (tree structures)
BRIDGE → separate an abstraction from its implementation (vary independently)
