Facade 模式为复杂的子系统提供了简化的接口 — 将其复杂性隐藏在一个单一的、清晰的入口点后面。它使一组复杂的组件更易于使用,而不会移除对底层细节的访问。
Facade 模式的作用
text
FACADE → a SIMPLE interface in front of a COMPLEX subsystem:
→ the subsystem has many components/steps; the facade provides ONE easy interface
→ clients use the simple facade instead of dealing with the complexity directly
→ the facade coordinates the underlying components
→ HIDE complexity behind a clean, easy-to-use interface
示例
js
{
() {
codec = ().(file);
decoded = ().(file, codec);
result = ().(decoded, format);
result;
}
}
().(, );
