Design Patterns · Middle · Question 3 of 75
How does Decorator differ from Proxy if their structure is similar?
- ✓Correct answer: By intent: Decorator adds behavior, Proxy controls access to the object
- 2Decorator works only with functions, Proxy only with classes
- 3Proxy always creates a new object, Decorator always mutates the original
Explanation
Both wrap an object with the same interface. Decorators are usually stacked to build up functionality (logging + cache + retry). A proxy manages lifecycle and access: lazy loading, permission checks, a remote object. Many patterns differ precisely by their goal.