Design Pattern Factory Pattern - Design Patterns

What is Design Pattern Factory Pattern?

Factory pattern is one of the most used design patterns in Java. This type of design pattern come under creational pattern as this pattern provides one of the best ways to build an objective.

In Factory pattern, we build entity without exposing the creation logic to the customer and refer to newly produced object using a universal interface.


We're obtainable to create a Shape interface and concrete classes implementing the form interface. A factory class Shape Factory is define as a next step.

FactoryPatternDemo, our presentation class will use Shape Factory to get a Shape article. It will pass information (CIRCLE / RECTANGLE / SQUARE) to form Factory to get the type of entity it needs.

Step 1

Create an interface.

Step 2

Make concrete classes implementing the similar interface.

Step 3

Construct a Factory to create object of concrete class based on given information.

Step 4

Apply the Factory to get entity of material class by momentary an information such as kind.

Step 5

Prove the output.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

Design Patterns Topics