Adapter vs Decorator vs Facade vs Proxy Design Pattern in Java
There is some striking similarity between Adapter, Decorator, Facade, and Proxy design patterns, in the sense that they all use Composition and delegation to solve the problem. The adapter pattern wraps an interface, and delegates call to it. The decorator wraps an object and implements behavior on top of that, Facade wraps one or more interfaces to provide a central interface, which is easy to use and Proxy Pattern also wraps Subject and delegates calls to it. Then questions come, why are different patterns? What is the difference between Adapter, Decorator, Facade, or Proxy pattern, if their structure is the same. The answer is Intent. Yes, all of these Java design patterns have similar structure and class diagrams but their intents are totally different from each other.
تعليقات
إرسال تعليق