Rakesh  avatar

Factory Design Pattern

rakeshbecse

Published: 01 Apr 2018 › Updated: 01 Apr 2018Factory Design Pattern

Factory Design Pattern

Factory Design Pattern:

  • It falls under Creational Design Pattern.
  • Factory pattern says that object creation will be handled by another class using the input type.

Advantages:

  • It allows loose-coupling.

When to use Factory Design Pattern?

  • Factory design pattern is used when we have a superclass with multiple sub-classes and based on the input, we need to return one of the sub-class.
  • Example: If a Restaurant serves Veg food, Non-Veg food, and Italian food. 
  • Treat VegFood, NonVegFood, and ItalianFood as three classes whose superclass is Food.
  • If a customer asks "Veg" then Factory method would return the "VegFood" class.

Leave Factory Design Pattern to:

Written by

I (Rakesh P ) am working in a product based software company in Chennai. I have been working in NLP (Natural Language Processing). When I was doing Engineering

Read more #softwaredesignpatterns posts


Best Posts From Rakesh

We have not curated any of rakeshbecse's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Rakesh