This is a typical example of the Factory Method Pattern.
这是个典型的Factory方法模式实例。
What's the right way to use the Factory method design pattern?
使用工厂方法设计模式的正确方法是什么?
Now, let us make sense of this definition for the Factory Method pattern.
现在,让我们在这个意义上定义的工厂方法模式。
Then, I use the factory method pattern so that the coupling is with the interface.
然后再使用工厂方法模式,这样耦合度就与界面相关联了。
The class returned by the factory method is an adapter to a particular cloud service.
工厂方法返回的类用于一个特定于服务的适配器。
Assure that the factory method is accessible to the target object and its subclasses.
确保目标对象及其子类可以访问工厂方法。
To create an instance of the Factory Method Pattern, perform the same steps as for the Singleton Pattern.
要创建Factory方法模式的实例,执行同Singleton模式相同的步骤。
The factory method pattern, as its name implies, defines the implementation of a method used to churn out objects.
而工厂方法模式,顾名思义,定义的是一个用来大量产出对象的方法的实现。
The Factory Method Pattern defines an interface for creating an object, but lets subclasses decide which class to instantiate.
工厂方法模式定义了一个创建对象的接口,但由子类决定实例化的逻辑。
You use the factory method pattern when an application needs to create objects whose type depend on the implementation of subclasses.
您可以在应用程序需要创建其类型依赖于子类的实现的对象时,使用工厂方法模式。
Patterns (such as the Factory Method mentioned in this article) are an important tool for understanding and discussing object-oriented design.
模式(如本文中提到的Factory Method模式)是理解和讨论面向对象设计的重要工具。
Create the SecurityManager instance based on the configuration (using Shiro’s Factory concept that represents the Factory Method design pattern).
根据配置创建SecurityManager实例(使用Shiro的工厂概念,它表述了 工厂方法设计模式);
Concrete classes provide the appropriate implementation for their respective base class. The Factory Method Pattern consists of the following classes.
concrete类为它们各自的基类提供恰当的实现。
The Factory Method Pattern is a creational pattern that defines an interface for creating an object but lets subclasses decide which actual class to instantiate.
Factory方法模式是一个创建的模式,它定义一个用来创建对象的接口,而让子类来决定实例化哪个类。
Apply the Extract method refactoring to this creation code, creating the factory method (discussed on page 110 of Fowler's book; see the Resources section for more information).
将抽取方法重构应用于这个创建代码,创建工厂方法(在Fowler书籍的第110页中讨论;有关更多信息,请参阅参考资料一节)。
At this point, you may be tempted to go one step further and replace the factory method with a full-fledged abstract factory object, as detailed in Design Patterns by Erich Gamma, et al.
此时,您可能很想更进一步并用成熟的抽象工厂对象替换工厂方法,如ErichGamma等人在设计模式中详细描述的那样。
Once data is initialized, Seam can place the resulting object into one of the available scopes where it can be read over and over without further participation of the factory method.
一旦初始化数据之后,Seam就可以将生成的对象放到一个可用的作用域中,然后就可以在其中反复读取,而不再需要借助工厂方法。
Because we overrode the factory method to write this test, it turns out that we no longer have any test coverage of the original creation code (which is now inside the base class's factory method).
因为我们覆盖了工厂方法来编写这个测试,所以其结果是:我们的测试不再包括任何原始创建代码(现在它在基类的工厂方法内部)。
Remember that once these options are set, they affect all instances obtained from the factory after the method invocation.
请记住,一旦设置了这些选项,在调用该方法之后,它们将影响所有从类厂获得的实例。
Finally, this method creates a column using the model element factory.
最后,该方法使用模型元素工厂创建一个列。
The singleton, builder, and factory method design patterns are considered creational patterns, as they assist in the construction of objects.
单例、生成器和工厂方法设计模式被视为是创建型的模式,因它们可协助对象的构建。
This section offers a step-by-step description of the Extract and Override factory method refactoring.
本节将循序渐进地描述“抽取”和“覆盖”工厂方法重构。
The new element creation technique (lines 15-16) differs both by the use of a QName object to represent the element name and by calling a method of the saved factory to build the element.
通过使用QName对象来表示元素名称和通过调用已保存的工厂的方法来构建元素可以区别新元素的创建技术(第 15-16 行)。
The solution here is to provide a method parameter with a factory method for the items to read, as shown in Listing 2.
这里的解决方案是为要读取的条目提供一个带工厂方法的方法参数,如清单2所示。
The @Factory annotation attaches a method to the creation process of an outjected variable, specified in the value of the annotation, when that variable has no value bound to it.
@Factory注释向已提取变量的创建过程附加了一个方法,这是在注释的值中指定的,当该变量没有绑定任何值时就会使 用该方法。
The @Factory annotation attaches a method to the creation process of an outjected variable, specified in the value of the annotation, when that variable has no value bound to it.
@Factory注释向已提取变量的创建过程附加了一个方法,这是在注释的值中指定的,当该变量没有绑定任何值时就会使 用该方法。
应用推荐