Decorator pattern เพิ่มพฤติกรรมหรือความรับผิดชอบให้กับอ็อบเจ็กต์แบบไดนามิกด้วยการห่อหุ้มมัน โดยไม่ต้องแก้ไขคลาสต้นฉบับ มันเป็นทางเลือกที่ยืดหยุ่นแทนการ subclass สำหรับการขยายฟังก์ชันการทำงาน ช่วยให้คุณประกอบพฤติกรรมต่าง ๆ ได้
Decorator pattern ทำอะไร
DECORATOR → WRAP an object to add behavior, keeping the same interface:
→ the decorator wraps the original, adds its behavior, and delegates to the original
→ you can STACK decorators (wrap a wrapped object) → compose multiple behaviors
→ adds functionality WITHOUT modifying the original class or using subclassing
→ "wrap to extend" — flexible, composable behavior addition
