Factory Method
The Factory method pattern attempts to solve the problems like code duplication, requiring information not accessible to the composing object, not having a sufficient level of abstraction and so forth. This design pattern handles these problems by defining a separate method for creating the objects, that uses sub classes which can then override to specify the type of the object to be created.
The Factory method pattern can use inheritance and delegate the object creation process to sub classes which use the factory method to create the objects.
The example source code can be found in GitHub.
References:
No comments:
Post a Comment