Describe, Compare, and Contrast several Creational Patterns.
Common Creational Patterns: Compare and Contrast
Creational design patterns focus on how objects are created.
In small programs, you can often call constructors directly without much risk.
In larger systems, however, object creation becomes a design concern because:
construction logic grows complex (many steps, many dependencies)
clients become tightly coupled to concrete classes
adding new variants forces widespread code changes
testing becomes harder when creation is scattered across the codebase
Creational patterns solve these problems by isolating creation logic
and letting clients depend on abstractions instead of concrete types. This supports
maintainability and extensibility, and it lines up cleanly with modern design goals
such as SOLID, dependency injection, and testable architecture.
Where This Lesson Fits in the Module
The Gang of Four (GoF) describes five core creational patterns:
Factory Method
Abstract Factory
Builder
Prototype
Singleton
In this module you have already seen Singleton, and you will explore
Factory Method in more detail later. This lesson focuses on comparing
three highly practical patterns that often appear in real codebases:
Abstract Factory (families of related objects)
Builder (step-by-step construction of complex objects)
Prototype (copy an existing object to create new instances)
Quick Definitions
Abstract Factory
Use Abstract Factory when your code must create multiple related objects
that should work together, but you want to avoid binding client code to a specific set of
concrete classes. This is common in UI toolkits, cross-platform libraries, and systems that
support “themes,” “drivers,” or “providers.”
Builder
Use Builder when creating an object requires multiple steps, optional parts,
or careful ordering. Builder separates how a complex object is assembled from the object
itself, enabling different representations from the same construction process.
Prototype
Use Prototype when creating a new object from scratch is expensive or complex,
and a copy of an existing object provides a better starting point. Instead of constructing a new
instance, the client clones a prototype and then customizes the clone as needed.
Compare and Contrast: When to Use Which
Although these patterns all address object creation, they solve different problems.
Here are the distinctions that matter most in practice.
1) Product Variants vs. Product Assembly
Abstract Factory selects which family of related products to create.
The focus is on compatibility between products (e.g., Windows UI widgets vs. Linux UI widgets).
Builder focuses on how to assemble a complex product step by step.
The focus is on construction workflow and producing different representations (HTML vs. XML, etc.).
2) New Construction vs. Copy Construction
Builder typically constructs new instances using a defined sequence of steps.
Prototype creates new instances by cloning an existing one—useful when setup cost is high
or when you need many similar objects with shared initial state.
3) How They Reduce Coupling
Abstract Factory reduces coupling by letting clients request “products” through abstract
interfaces—clients never name concrete classes.
Builder reduces coupling by separating the construction process from the product’s
final representation.
Prototype reduces coupling by replacing “new + configure” logic with “clone + tweak,”
hiding complex initialization behind copying.
Modern Context: How These Patterns Show Up Today
Even in modern ecosystems with dependency injection and frameworks, these patterns remain relevant:
Abstract Factory appears in provider-based APIs where implementations are selected at runtime
(platform-specific factories, plugin systems, environment-specific services).
Builder is common in fluent APIs and configuration-heavy objects (request builders, query builders,
immutable configuration objects).
Prototype is practical in systems that create many complex objects efficiently (templating, caching,
UI component duplication, game entities, document models).
The key idea is not to memorize pattern names, but to recognize the underlying creation problem:
family selection, step-by-step assembly, or copy-based instantiation.
1) Abstract Factory defines an interface for creating families of related objects without specifying concrete classes. The java.awt.Toolkit class is a classic example, providing platform-specific UI peers through a common factory interface.
2) Builder separates construction of a complex object from its representation.
A Director can feed the same data into different Builders to produce HTML, XML, or PostScript outputs.
3) Prototype creates new objects by copying an existing instance. Changing the prototype changes what gets created.
This is useful when you need many copies of a complex object with shared initial state.