Skip to content

Factory

Code Implementation

FactoryDp

Intent

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

Also called - Virtual Constructor

It promotes the loose-coupling by eliminating the need to bind application-specific classes into the code.

factory.png