静态工厂方法 meaning in English
static factory method
Examples
- One advantage of static factory methods is that , unlike constructors , they have names
静态工厂方法的一个好处是,与构造函数不同,静态工厂方法具有名字。 - In summary , static factory methods and public constructors both have their uses , and it pays to understand their relative merits
总而言之,静态工厂方法和构造函数均有各自的适用性,掌握他们不同的适用场所是很有用的。 - Avoid the reflex to provide constructors without first considering static factories because static factories are often more appropriate
尽量避免不作考虑使用静态工厂方法而直接使用构造函数,因为静态工厂方法在大多数情况下都比构造函数更加适用。 - You can often avoid creating duplicate objects by using static factory methods in preference to constructors on immutable classes that provide both
对于同时提供了静态工厂方法和构造函数的非可变类,通常可以用静态工厂方法而不是构造函数来避免创建重复的对象。