Factory Method

xiaoxiao2021-03-06  102

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.

转载请注明原文地址:https://www.9cbs.com/read-124965.html

New Post(0)