Facade pattern ให้ interface ที่เรียบง่าย ไปยัง subsystem ที่ซับซ้อน โดยซ่อนความซับซ้อนของมันไว้หลังจุดเข้าเดียวที่สะอาด มันทำให้ชุดของ component ที่ซับซ้อนใช้งานได้ง่ายขึ้น โดยไม่ตัดการเข้าถึงรายละเอียดภายในออกไป
Facade pattern ทำอะไร
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
ตัวอย่าง
{
() {
codec = ().(file);
decoded = ().(file, codec);
result = ().(decoded, format);
result;
}
}
().(, );
