工厂方法模式与继承

Factory Method Pattern vs inheritance

使用这个模式有什么意义? 考虑到这篇文章,它只是毫无意义:https://refactoring.guru/design-patterns/factory-method

为什么不使用简单继承? 这是一个小比较: https://codesandbox.io/s/factory-method-pattern-vs-good-old-inheritance-opovv?file=/src/inheritance.ts

没有人与人相对;工厂方法通过继承使用多态性将对象创建推迟到子类。

不要将模式混淆为大于其成分。模式只是软件设计常见用例的名称,因为任何重要的东西都应该有一个名称。