Skip to main content


Showing posts with the label Abstract Factory Design pattern

Design patterns - Abstract Factory with Java Example

Introduction Abstract Factory design pattern comes under creational design pattern. It is also called factory of factories . It provides a way to encapsulate a group of factories which have common behaviour or theme without specifying which underlying concrete objects are created. It is one level of abstraction higher than Factory pattern. In Factory Design Pattern , we get instance of one of several sub-classes whereas in Abstract Factory Design pattern we get instance of one of several factories which then get instance of one of several sub-classes . Implementation We are going to create Factories for Import and Export. We have one producer class ImportExportFactoryProducer which produces the factory based on type i,e. if instance of ImportFactory is required or ExportStrategy is required which then initialize the concrete classes for ImportStrategy or ExportStrategy . 1. AbstractFactoryTest class package com . gauravbytes . test ; import com.gauravbytes ._impor