Creational Design Patterns
Patterns for object creation: Singleton, Factory Method, Abstract Factory, Builder, and Prototype with intents and use cases.
Patterns for object creation: Singleton, Factory Method, Abstract Factory, Builder, and Prototype with intents and use cases.
Creational design patterns that control how objects are created: Singleton, Factory Method, Abstract Factory, Builder and Prototype, plus Object Pool, Lazy Initialization and Dependency Injection, each with intent and when to use it.
| Name | Intent | When to use |
|---|---|---|
| Singleton | Ensure a class has only one instance | Shared resource access, global state |
| Factory Method | Create objects without specifying exact class | Decoupling object creation from usage |
| Abstract Factory | Create families of related objects | Multiple product variants |
| Builder | Construct complex objects step by step | Many configuration options |
| Prototype | Create new objects by copying existing ones | Object creation is costly |
| Object Pool | Reuse a set of expensive-to-create objects instead of creating and destroying them on demand | Database connections, threads and other costly resources |
| Lazy Initialization | Delay creating an object or computing a value until it is first needed | Expensive objects that may never be used |
| Dependency Injection | Supply an object's dependencies from outside instead of letting it construct them | Testing, configuration and swapping implementations without changing callers |
The shape of this dataset, read from the data itself: every column, its type and a real value. Agents can use this to plan a query without fetching the whole document.
| Section | Field | Type | Example |
|---|---|---|---|
| patterns | name | string | Singleton |
| patterns | intent | string | Ensure a class has only one instance |
| patterns | when_to_use | string | Shared resource access, global state |
The static files contain the same reference rows as the API, with no API rate limit. Live metadata, such as view counts, may differ. Use the API for content negotiation; use the static files for a cacheable snapshot.
curl "https://yjtoon.yunusemrevurgun.com/api/dataset/creational-patterns?format=toon"
const res = await fetch( "https://yjtoon.yunusemrevurgun.com/static-data/dataset/creational-patterns.toon" ); const toon = await res.text();
Rate limit: 120 requests per minute per IP, no key and no signup. API reference →