Creational patterns move object-construction decisions away from the code that uses the result. The pressure is not the new keyword itself. It is construction knowledge that is repeated, varies by context, or must preserve an invariant across several objects. Factory Method and Abstract Factory choose implementations, Builder stages complex assembly, Prototype copies an existing configuration, and Singleton constrains lifetime and access.
Patterns at a Glance
The patterns solve different construction problems. The condition in the last column matters more than the pattern name.
| Pattern | Intent | Reach for it when |
|---|---|---|
| Software Architecture/Patterns/Design Patterns/Creational/Factory Method | Define an interface for creating an object, but let subclasses decide which concrete class to instantiate. | One product type varies by context, and new variants should arrive as subclasses instead of edits to existing code. |
| Software Architecture/Patterns/Design Patterns/Creational/Abstract Factory | Provide an interface for creating families of related objects without naming their concrete classes. | Products must stay mutually compatible (a whole Stripe / PayPal provider family swapped together), with new families expected over time. |
| Software Architecture/Patterns/Design Patterns/Creational/Builder | Separate construction of a complex object from its representation, assembling it step by step. | Construction needs cross-field validation, computed fields, or a director-driven sequence — beyond what required / init object initializers cover. |
| Software Architecture/Patterns/Design Patterns/Creational/Prototype | Create new objects by copying an existing instance rather than constructing from scratch. | Construction is expensive, or many near-identical variants must be cloned from a template (idiomatically record with { }). |
| Software Architecture/Patterns/Design Patterns/Creational/Singleton | Ensure a class has only one instance and give it a single global access point. | Exactly one shared instance should serve the whole application — in modern .NET, prefer AddSingleton<T>() over the classical static form. |
Questions
How do Factory Method and Abstract Factory differ?
Factory Method uses inheritance: a creator subclass chooses one product implementation for a step in its workflow. Abstract Factory uses composition: an injected factory creates several related products as one family. Factory Method fits when one creation step varies. Abstract Factory fits when a whole compatible set must change together.