1.2.3. Object Adapter vs Proxy

From the book:

In the proxy pattern, the RealSubject implements the Subject interface. If we take away the inheritance relationship, is this still a proxy or does it become an adapter? Similarly, if in an adapter the Adaptee happens to implement Target, does the pattern become a proxy?

It depends on the intent. For example, with session beans in EJB, the implementation bean does not inherit directly from the remote interface, because the methods throw incompatible exceptions. The remote interface would throw RemoteException, whereas the implementation bean would throw business exceptions.

An object adapter has a similar structure to the proxy. In both cases, the client uses the top-level interfaces Target or Subject. We have implementations of this interface in Adapter or Proxy.

Complete and Continue  
Discussion

0 comments