Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
来自四人组的设计模式
为什么component装饰器对被装饰物的引用Decorator指向被装饰物的接口Component,
component
Decorator
Component
realSubject而代理的引用Proxy指向具体RealSubject?
realSubject
Proxy
RealSubject
谢谢。
代理可以专门指向其主题的接口。GoF 提到,
ProxySubject如果RealSubject和Subject接口相同,可以指a 。
Subject
但是根据实现,代理可以通过调用构造函数来实例化它的主体,这需要引用一个具体的对象。