Java Design Pattern – Factory Pattern

Factory Pattern is a kind of Creation Pattern. Factory Pattern provides an interface for integration and hidden the complex implementation of related components.

The tutorial will help you create a factory pattern based on concept above.

I. Technology use for Factory Pattern

– Java 8
– Eclipse: Version: Mars.2 Release (4.5.2)

II. Overview Tutorial

java factory design pattern uml

Create a Car Factory Pattern as Java classes:
– Car interface
– Implements Car interface: Audi class, BMW class, Mercedes class.
– Implements Car Factory: CarFactory class.
– CarType class: defines all kind of car that Car Factory products.

java factory design pattern

III. Practices
1. Create a Car Interface

2. Implement Car Interface

– Create Audi class:

– Create BMW class:

– Create Mercedes class:

3. Define Car Type

– Create CarType enum:

4. Create Car Factory

– Create CarFactory class:

5. Create Main Class

IV. Run


V. Sourcecode

java factory design pattern

By grokonez | October 14, 2016.

Last updated on June 4, 2017.

Related Posts

Got Something To Say:

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