RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:9:30-18:00
你可能遇到了下面的问题
关闭右侧工具栏
Factory Method
  • 作者:xiaoxiao
  • 发表时间:2020-12-23 11:02
  • 来源:未知

BenefitsIt removes the need to bind application-specific classes into the code. The code interacts solely with the resultant interface, so it will work with any classes that implement that interface.Because creating objects inside a class is more flexible than creating an object directly, it enables the subclass to provide an extended version of an object.

Applicable ScenariosA class is not able to anticipate the class of objects it needs to create.A class wants its subclasses to specify the objects it instantiates.Classes assign responsibility to one of several helper subclasses, and you want to localize the knowledge of which helper subclass is the delegate.