<aside>

This section is part of the 5-hour LLD course by Mukul Raina

SLIDE 41: Section Intro: Creational Design Patterns

Section 4: Creational Design Patterns

Creational patterns address a specific problem: how and where objects get created. In a small codebase, calling new SomeClass() everywhere is fine. In a larger system, scattered object creation leads to tight coupling, duplicated configuration logic, and classes that are impossible to test in isolation. Creational patterns centralize and control object creation so that the rest of your code depends on abstractions rather than concrete classes. This is the Dependency Inversion Principle from Section 3 applied specifically to construction.

What We Will Cover

  1. Factory Method: decoupling object creation from usage
  2. Abstract Factory: creating families of related objects consistently
  3. Builder: constructing complex objects step by step
  4. Singleton: when it is genuinely appropriate and why it is overused
  5. Creational pattern decision framework

Where Creational Patterns Appear in LLD Interviews

Interview Signal Creational Pattern Why
“Support multiple types of X” Factory Method Decouple creation from the calling code
“These objects must be created together consistently” Abstract Factory Ensure compatible object families
“This object has 8+ constructor parameters” Builder Avoid telescoping constructors
“We need exactly one instance of X” Singleton (cautiously) Controlled shared state
“How would you add a new type without changing existing code?” Factory Method OCP applied to object creation

<aside>

Mukul Raina | youtube.com/@mukulraina | slides.mukulraina.com | LinkedIn

</aside>


SLIDE 42: Factory Method: Decoupling Object Creation from Usage

The Factory Method pattern moves object creation out of the calling code and into a dedicated method or class. The calling code requests an object through the factory and receives it through an interface, without knowing which concrete class was instantiated.

Why This Matters

When creation logic is scattered across the codebase, every class that creates objects is coupled to the concrete implementations. If you have 15 classes that each call new EmailNotification(), switching from email to push notifications requires editing 15 files. A factory centralizes this decision into one place.

The Core Idea