Sunday, February 28, 2010

Design Patterns: Decorator and Proxy

Continuing the search to find just the right way to describe the difference between the Proxy and the Decorator patterns. The best one I've found so far is here. To summarize... the Proxy pattern establishes the target object at compile time while the Decorator pattern establishes the target at run time. This allows the Decorator pattern to also be nested many levels as the target object (being either the original target or a decorated target) is passed in to the decorator as a parameter. The Proxy would be a single level deep as the target is instantiated inside the proxy itself.

No comments:

Post a Comment