Decorator pattern اشیاء کو wrap کر کے ان میں رویہ یا ذمہ داریاں متحرک طریقے سے شامل کرتا ہے — اصل کلاس میں ترمیم کیے بغیر۔ یہ functionality کو بڑھانے کے لیے subclassing کے لیے ایک لچکدار متبادل فراہم کرتا ہے، جو آپ کو رویے کو ترکیب کرنے دیتا ہے۔
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
