Wednesday, 18 September 2019

Factory Pattern - Live example


Factory Pattern - Live example


Definition:

Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.

Example: Download

Taken a abstract class/interface which contain all factory methods(definitions/signatures).

Base Class: declare all abstract methods

Child Class 1: inherit base class
Child Class 2: inherit base class
In the creator class, object instance will create dynamically based on configuration.




No comments:

Post a Comment