Factory Design Pattern in Java with Example | Java Guides

Published: 28 March 2020
on channel: Java Guides
8,924
134

In this video tutorial, we will look into how to implement a Factory design pattern in Java with an example.

Get the source code of this tutorial from my blog post at https://www.javaguides.net/2020/03/fa....

The factory design pattern overview:

1. Factory Pattern is one of the Creational Design Pattern.
2. The Factory Design Pattern or Factory Method Pattern is one of the most used design patterns in Java.
3. In the Factory pattern, we create an object without exposing the creation logic to the client and refer to newly created objects using a common interface.
4. The factory design pattern is used when we have a superclass with multiple sub-classes and based on input, we need to return one of the sub-class. This pattern takes out the responsibility of the instantiation of a class from the client program to the factory class.

When to Use Factory Method Design Pattern:

1. When the implementation of an interface or an abstract class is expected to change frequently.
2. The factory design pattern is used when we have a superclass with multiple sub-classes and based on input, we need to return one of the sub-class. This pattern takes out the responsibility of the instantiation of a class from the client program to the factory class.
3. The lifetime management of the generated objects must be centralized to ensure consistent behavior within the application.

#designpatterns #java #javaguides


On this page of the site you can watch the video online Factory Design Pattern in Java with Example | Java Guides with a duration of hours minute second in good quality, which was uploaded by the user Java Guides 28 March 2020, share the link with friends and acquaintances, this video has already been watched 8,924 times on youtube and it was liked by 134 viewers. Enjoy your viewing!