QuickDevGuide

Home › Design Patterns

Creational Patterns — Design Patterns

Singleton Singleton: Ensures only one instance of a class exists globally — commonly used for database connection pools, loggers, and configuration managers. Use sparingly because singletons introduce global state and make testing harder. Factory Method Factory Method: Creates objects without specifying exact classes, using a factory interface. The client code works with the interface while the factory decides which concrete class to instantiate. Essential for plugin systems and dependency injection. Builder Builder: Constructs complex objects step-by-step — especially useful when constructors have many parameters. Each method returns this, enabling method chaining for readable object construction.

Key Takeaways