Proxy vs Decorator design patterns, both seems similarity structurally with different intent. Let me explain the similarity and differences between them.
1. Proxy Design Pattern
control Access to it.
What is proxy?
It’s an intermediary between a client object and the target object. responsibility wise it, It receives a call from client object and forwards them to the target Object. You can visit proxy design patterns for more details.
2. Decorator Design Pattern
adds additional responsibility at run-time
3. Key Points Proxy vs Decorator design patterns
Following are the high level differences between Proxy and Decorator design patterns. Both looks like similar structuraly but intent of both are different.
- Target Object accessibility: The client object can not access target object directly while Client object has ability to access target object directly.
- Access level: Proxy object provides access control to the target object, decorator does not control access to target object.
- Responsibility level: Proxy does not add any additional responsibility while Decorator add additional responsibility to an object.
I hope you enjoyed this post of Proxy vs Decorator design patterns, and you can visit design patterns tutorial for more details.
Suggestions are welcome to improve this post. Happy Learning 🙂
Please write your comment to improve this post.