java - Differences between Proxy and Decorator Pattern -
can give explanation difference between proxy , decorator?
the main difference see when assume proxy uses composition , decorator uses aggregation seems clear using multiple (one or more) decorators can modify/ add functionalities pre-existing instance (decorate), whereas proxy has own inner instance of proxied class , delegates adding additional features (proxy behaviour).
the question - proxy created aggregation still proxy or rather decorator? allowed (by definition in gof patterns) create proxy aggregation?
decorator pattern focuses on dynamically adding functions object, while proxy pattern focuses on controlling access object.
edit:-
relationship between proxy , real subject typically set @ compile time, proxy instantiates in way, whereas decorator assigned subject @ runtime, knowing subject's interface.
Comments
Post a Comment