When to use Factory method pattern?

后端 未结 10 1455
南旧
南旧 2020-12-12 14:56

When to use Factory method pattern?

Please provide me some specific idea when to use it in project? and how it is a better way over new keyword?

10条回答
  •  借酒劲吻你
    2020-12-12 15:38

    Factory method pattern can be used when there is a need to generate objects that belong to specific family. Along side this requirement, you also want to keep the decisions made regarding object instantiation in one place.

    Please refer the following link for more details.

    http://xeon2k.wordpress.com/2010/11/27/factory-method-pattern/

提交回复
热议问题