Creational Patterns


Object creation control. When making an object is expensive, or the exact type isn’t known until runtime, or you need exactly one instance, exactly one family of related instances, or a fast supply of near-identical copies, one of these six covers it.

  • Singleton Guarantees exactly one instance exists, and makes the lazy double-checked construction safe when multiple threads race to create it first.
  • Factory Method One method owns “which concrete class to build,” so every caller picks a type without duplicating the same if/else ladder.
  • Abstract Factory Guarantees every object built through one factory belongs to the same family, so you can’t accidentally mix a Windows audio player with a VLC video player.
  • Builder Splits required fields, enforced in the constructor, from optional ones set via chained calls, so you skip telescoping constructors and half-built objects.
  • Prototype Clones existing instances instead of rebuilding from scratch, using copy constructors instead of Java’s Cloneable.
  • Object Pool Reuses a fixed set of expensive objects instead of constructing and discarding a fresh one per request.

← Back to Design Patterns

Want to get blog posts over email?

Enter your email address and get notified when there's a new post!

Comments