最简单的方法就是在工厂模式中把代理类的建立封装起来。
The simplest approach is to encapsulate the creation of the proxy class within the Factory pattern.
您可以在应用程序需要创建其类型依赖于子类的实现的对象时,使用工厂方法模式。
You use the factory method pattern when an application needs to create objects whose type depend on the implementation of subclasses.
清单6用工厂模式,在Layout类中创建了Field。
Listing 6 creates a Field using the Factory pattern in the Layout class.
应用推荐