Decorator pattern हे गतिमानपणे वस्तूंना वर्तन किंवा जबाबदाऱ्या जोडते त्यांना गुंडाळून — मूळ वर्गातील बदल न करता. हे कार्यक्षमता वाढविण्यासाठी सबक्लासिंगचा एक लचकदार पर्याय प्रदान करते, ज्यामुळे तुम्हाला वर्तने एकत्र करता येतात.
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
