Creational Patterns

In software engineering, creational design patterns are design patterns that deal with object creation mechanisms, trying to create objects in a manner suitable to the situation. Creational design patterns are composed of two dominant ideas. One is encapsulating knowledge about which concrete classes the system uses. Another is hiding how instances of these concrete classes are created and combined.

The creational patterns aim to separate a system from how its objects are created, composed, and represented. They increase the system’s flexibility in terms of the what, who, how, and when of object creation.

Consider applying creational patterns when:

A system should be independent of how its objects and products are created.
A set of related objects is designed to be used together.
Hiding the implementations of a class library or product, revealing only their interfaces.
Constructing different representation of independent complex objects.
A class wants its subclass to implement the object it creates.
The class instantiations are specified at run-time.
There must be a single instance and client can access this instance at all times.
Instance should be extensible without being modified.

Related Tags

Tutorials

java-design-patterns

Builder Design Pattern in Java

Learn the Builder pattern in Java with classic, generic and Lombok implementations. Compare defaults, validation and mutable versus immutable results.

Prototype Design Pattern in Java

Learn the Prototype pattern in Java with a newsletter campaign example. Compare shallow and deep copies, copy constructors, Cloneable and prototype registries.

Factory Design Pattern in Java

Learn simple factories and Factory Method in Java with working text and HTML preview examples, participant diagrams, output and error handling.

Singleton Design Pattern in Java

Learn how Java Singleton works with enum and holder implementations, runnable code, thread-safety limits, serialization, and practical alternatives.

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.