Creational
10 items tagged with "creational"
Patterns10
Factory Method
Defines an interface for creating an object but lets subclasses decide which concrete class to instantiate, deferring instantiation to subclasses.
Abstract Factory
Provides an interface for creating families of related objects without specifying their concrete classes, ensuring products from one family are used together.
Builder
Separates the construction of a complex object from its representation so the same construction process can create different representations step by step.
Prototype
Creates new objects by cloning an existing instance (the prototype) rather than instantiating a class, useful when construction is costly or types are decided at runtime.
Singleton
Ensures a class has only one instance and provides a global point of access to it, used for shared resources like configuration, logging, or connection pools.
Object Pool
Reuses a set of pre-initialized, expensive-to-create objects from a managed pool instead of creating and destroying them on demand, improving performance.
Dependency Injection
Supplies an object's dependencies from the outside rather than having it construct them, inverting control to improve testability, flexibility, and decoupling.
Lazy Initialization
Defers the creation or computation of an object until the first time it is actually needed, avoiding upfront cost for resources that may never be used.
Multiton
Generalizes Singleton to manage a fixed, keyed set of named instances, ensuring exactly one instance exists per key through a registry.
Registry
Provides a well-known central object where shared instances or services can be registered and looked up by key, giving a single point of access without scattered globals.