V2EX  ›  英汉词典

Factory Method

定义 Definition

Factory Method(工厂方法):一种面向对象的创建型设计模式。它把“创建对象”的过程封装到一个方法中,由子类或具体实现决定实例化哪一种具体类,从而让代码在不直接依赖具体类的情况下创建对象。(除设计模式外,method 也可泛指“方法/步骤”,但此处最常见指设计模式。)

发音 Pronunciation (IPA)

/ˈfæktəri ˈmɛθəd/

例句 Examples

We used a factory method to create the right object.
我们使用工厂方法来创建合适的对象。

By applying the Factory Method pattern, the library lets subclasses decide which parser to instantiate, reducing coupling and improving extensibility.
通过应用工厂方法模式,这个库让子类决定实例化哪种解析器,从而降低耦合并提升可扩展性。

词源 Etymology

factory(工厂,隐喻“生产/创建”)+ method(方法)组成。在软件工程语境中,“工厂”被借用来表示“负责创建对象的组件/方法”。“Factory Method”作为术语在面向对象设计与设计模式讨论中被系统化并广泛传播。

相关词 Related Words

文学与著作 Literary Works

  • Design Patterns: Elements of Reusable Object-Oriented Software(《设计模式:可复用面向对象软件的基础》)
  • Head First Design Patterns(《深入浅出设计模式》)
  • Refactoring: Improving the Design of Existing Code(《重构:改善既有代码的设计》)
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   1916 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 11ms · UTC 14:45 · PVG 22:45 · LAX 06:45 · JFK 09:45
♥ Do have faith in what you're doing.