Mid
From PDF
SOLID
Design Patterns & SOLID
How does the Decorator pattern differ from the Proxy pattern?
Short answer: Decorator adds additional responsibilities to objects dynamically without altering their interface. It wraps the original object to extend behavior. Proxy controls access to an object, possibly adding lazy initialization, access control, or logging, without changing its interface.
Real-world example (ShopNest)
ShopNest payment fees use Strategy: IFeeCalculator with UPI/Card implementations chosen at runtime.
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png