vendredi 15 janvier 2021

Proxy Design Pattern: Association to the Interface or to RealSubject


I am currently learning the proxy pattern and have found two different implementations of it in two different books. Please see the links for patterns UML Diagrams as I cannot embed the pictures yet.

Pattern 1

Pattern 2

My teacher says that Pattern 1 is the correct implementation, although most of the tutorials and sources use the Pattern 2 implementation. My teacher argues that Pattern 2 is wrong because "It allows the proxy to call all public methods on the RealSubject, which makes it not really different from the adapter pattern", while Pattern 1 "enforces that the proxy only can call the functions from the interface class inside the real subject"

My questions are:

  1. What are the real differences between these two UML diagrams? Don't they show the same thing in essence?
  2. If Pattern 2 is wrong, why does the majority of sources, including books, use it to show the Proxy pattern?

Thank you for your answers.

Aucun commentaire:

Enregistrer un commentaire