Proxy模式與Decorator模式的區別

tomsonxu發表於2006-05-11
看了一篇文章(http://www.javaworld.com/javaworld/jw-02-2002/jw-0222-designpatterns.html)說到:

兩個模式比較相似,因為Both patterns use a proxy that forwards method calls to another object, known as the real subject.

兩模式的不同之處在於:with the Proxy pattern, the relationship between a proxy and the real subject is typically set at compile time, whereas decorators can be recursively constructed at runtime。

不是很能理解上面所說的不同之處,請各位指教(最好可以舉例說明)。謝謝。

相關文章