From factory method to abstract factory.
从工厂方法到抽象工厂。
Refactoring: Extract and override factory method.
重构:抽取和覆盖工厂方法。
Using a static factory method to create a Msg object.
使用静态工厂方法创建一个msg对象。
A factory method, by convention, begins with create and returns the interface.
根据约定,factory方法将以create为开头并返回接口。
Assure that the factory method is accessible to the target object and its subclasses.
确保目标对象及其子类可以访问工厂方法。
This section offers a step-by-step description of the Extract and Override factory method refactoring.
本节将循序渐进地描述“抽取”和“覆盖”工厂方法重构。
This factory method instantiates the collection of course objects by delegating the work to the service layer.
该工厂方法通过将这项工作委托给服务层来实例化课程对象集合。
The factory method pattern, as its name implies, defines the implementation of a method used to churn out objects.
而工厂方法模式,顾名思义,定义的是一个用来大量产出对象的方法的实现。
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 example gave a client and server bundle (both in the same VM), and the client found the server via a factory method.
文中的例子给出了一个client和一个serverbundle(两者在同一个VM中),client通过工厂方法找到server。
In fact, many would have started this approach with a factory object, rather than a factory method — we did, but soon backed away.
实际上,许多人已经用工厂对象来着手这种方法,而不是用工厂方法—我们以前是这样做的,但很快就放弃了。
Optional: create a unit test to assure that the original target object's factory method still returns the correct, non-mock object.
可选的:创建单元测试以确保原始目标对象的工厂方法仍返回正确的非模仿对象。
You use the factory method pattern when an application needs to create objects whose type depend on the implementation of subclasses.
您可以在应用程序需要创建其类型依赖于子类的实现的对象时,使用工厂方法模式。
In this way, the object returned from the static factory method could implement any number of interfaces defined when I create the proxy.
用这种方式,静态工厂方法返回的对象可以实现建立代理时所定义的任意数量的接口。
You can retrieve an MXBean instance from a static factory method that gives you direct access to the locally running JVM's MXBean interface.
您可以从一个静态工厂方法获得一个MXBean实例,该方法可以使您直接访问本地运行的JVM的MXBean接口。
The singleton, builder, and factory method design patterns are considered creational patterns, as they assist in the construction of objects.
单例、生成器和工厂方法设计模式被视为是创建型的模式,因它们可协助对象的构建。
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页中讨论;有关更多信息,请参阅参考资料一节)。
In Listing 2, the code first includes the necessary class file for the MDB2_Schema package, and then initializes the MDB2 abstraction layer by calling its static factory method.
在清单2中,代码首先包含了MDB2_Schema包所需的类文件,然后通过调用其静态方法factory以初始化mdb2抽象层。
The getCalculator() factory method currently takes the very simple approach of assuming that all calculators created by this service will be accessed via the same service endpoint.
目前, getCalculator()工厂方法采用了非常简单的方法,它假定由这个服务所创建的全部计算器都是通过相同的服务端点来访问的。
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就可以将生成的对象放到一个可用的作用域中,然后就可以在其中反复读取,而不再需要借助工厂方法。
The heuristic for identifying static factory methods is somewhat basic and could be confused by a method that looks like a factory method but actually performs a different operation.
用于识别静态factory方法的启发法还比较基本,可能会与看上去像是factory方法但实际上执行不同操作的方法产生混淆。
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等人在设计模式中详细描述的那样。
Tiger allows us to declare type parameters at the level of individual methods by prefixing them to method declarations. For example, we could do so for our factory method make as follows.
Tiger让我们通过将类型参数作为方法声明的前缀,从而在单独的方法级别上声明类型参数。
The factory implementation produced by the wizard offers a convenient shortcut that allows overriding of the basic factory method so a URL can be passed to the factory when the stub is created.
由向导生成的工厂实现提供了一个简化操作,就是允许覆写基本的工厂方法,因此当存根被创建时URL就可以被传递到工厂。
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).
因为我们覆盖了工厂方法来编写这个测试,所以其结果是:我们的测试不再包括任何原始创建代码(现在它在基类的工厂方法内部)。
This is a typical example of the Factory Method Pattern.
这是个典型的Factory方法模式实例。
To create an instance of the Factory Method Pattern, perform the same steps as for the Singleton Pattern.
要创建Factory方法模式的实例,执行同Singleton模式相同的步骤。
Patterns (such as the Factory Method mentioned in this article) are an important tool for understanding and discussing object-oriented design.
模式(如本文中提到的Factory Method模式)是理解和讨论面向对象设计的重要工具。
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方法模式是一个创建的模式,它定义一个用来创建对象的接口,而让子类来决定实例化哪个类。
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方法模式是一个创建的模式,它定义一个用来创建对象的接口,而让子类来决定实例化哪个类。
应用推荐