How Decorator design pattern is different from Proxy pattern?

Main differences between Decorator and Proxy design pattern are:

  • Decorator provides an enhanced interface after decorating it with additional features. Proxy provides same interface since it is just acting as a proxy to another object.
  • Decorator is a type of Composite pattern with only one component. But each decorator can add additional features. Since it is one component in Decorator, there is no object aggregation.
  • Proxy can also provide performance improvement by lazy loading. There is nothing like this available in Decorator.
  • Decorator follows recursive composition. Proxy is just one object to another object access.
  • Decorator is mostly used for building a variety of objects. Proxy is mainly used for access to another object.

Leave a Reply

Your email address will not be published. Required fields are marked *