Factory Design Pattern

Factory Design Pattern: (Singleton Design Pattern here)
What is Factory Design Pattern?
We need to define an interface or abstract class to create an object and we allow the subclasses to decide which class to instantiate.

What is the main advantage of Factory Pattern?
The main advantage of factory pattern is Loosely-Coupling. More flexibility, We can change the implementation type without changing the dependent code.

Example,

Project Structure:
structure

department.java

ComputerScience.java

InformationTechnology.java

FactoryPattern.java

FactoryPatternExecution.java

Output:
op

 

 Singleton Design Pattern here

 

 

 

One thought on “Factory Design Pattern

Leave a Reply

Your email address will not be published. Required fields are marked *