Factory Design Pattern in Java with Example | Java Guides

Veröffentlicht am: 28 März 2020
auf dem Kanal: 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


Auf dieser Seite können Sie das Online-Video Factory Design Pattern in Java with Example | Java Guides mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Java Guides 28 März 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 8,924 Mal angesehen und es wurde von 134 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!