一个静态的泛型和非泛型类工厂方法?
A static factory method on a generic or a non-generic class?
工厂方法返回的类用于一个特定于服务的适配器。
The class returned by the factory method is an adapter to a particular cloud service.
它们不像实例方法那样常见,但您将会经常看到一些类方法,它们作为创建新的类实例的工厂方法;这免得您必须进行分配和初始化。
These are not as common as instance methods, but you will often see class methods that are factory methods for creating new instances of the class; this saves you from having to alloc and initialize.
因为我们覆盖了工厂方法来编写这个测试,所以其结果是:我们的测试不再包括任何原始创建代码(现在它在基类的工厂方法内部)。
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 can be as simple as invoking the base class's factory method and asserting that the returned object is of the correct type. For example.
bosession类提供创建该类的实例的静态工厂方法,封装用来访问Notes数据库的NotesSession实例。
The BOSession class offers static factory methods to create an instance of this class which encapsulates a Notes Session instance used to access the Notes database.
这个工厂类将变成由相互依赖的工厂方法构成的巨型蜘蛛网。
This factory is going to become a huge spiderweb of interdependent factory methods!
定义一个用于创建对象的接口,让子类决定实例化哪一个类。工厂方法使一个类的实例化延迟到其子类。
Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.
第一个类使用构造函数初始化属性,第二个类使用静态工厂方法。
The first class USES a constructor to initialize the properties, and the second class USES a static factory method.
定义一个用于创建对象的接口,让子类决定实例化哪一个类。工厂方法使一个类的实例化延迟到其子类。
Define an interface for creating an object, but let subclass decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.
工厂方法让一个类的实例化延迟到子类中进行。
Factory Method lets a class defer instantiation to subclasses.
工厂方法让一个类的实例化延迟到子类中进行。
Factory Method lets a class defer instantiation to subclasses.
应用推荐