{
    "api": "YAML JSON TOON Database",
    "version": "1.0.0",
    "format": "json",
    "dataset": {
        "id": 9,
        "slug": "creational-patterns",
        "title": "Creational Design Patterns",
        "description": "Patterns for object creation: Singleton, Factory Method, Abstract Factory, Builder, and Prototype with intents and use cases.",
        "summary": "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.",
        "use_when": [
            "You need to decouple code from the concrete classes it instantiates.",
            "You are choosing among factory-style patterns."
        ],
        "caveats": [
            "Singleton is often overused and acts as hidden global state; dependency injection is usually a better alternative.",
            "Dependency injection is a technique rather than a Gang of Four pattern, listed here because it addresses the same problem."
        ],
        "related": [
            "structural-patterns",
            "behavioral-design-patterns",
            "solid-principles",
            "architectural-design-patterns"
        ],
        "category": "Design Patterns",
        "category_slug": "design-patterns",
        "tags": "design patterns,oop,software engineering",
        "view_count": 0,
        "created_at": 1777673262,
        "updated_at": 1777673262,
        "entry_count": 8,
        "fields": [
            {
                "section": "patterns",
                "field": "name",
                "type": "string",
                "example": "Singleton"
            },
            {
                "section": "patterns",
                "field": "intent",
                "type": "string",
                "example": "Ensure a class has only one instance"
            },
            {
                "section": "patterns",
                "field": "when_to_use",
                "type": "string",
                "example": "Shared resource access, global state"
            }
        ]
    },
    "data": {
        "patterns": [
            {
                "name": "Singleton",
                "intent": "Ensure a class has only one instance",
                "when_to_use": "Shared resource access, global state"
            },
            {
                "name": "Factory Method",
                "intent": "Create objects without specifying exact class",
                "when_to_use": "Decoupling object creation from usage"
            },
            {
                "name": "Abstract Factory",
                "intent": "Create families of related objects",
                "when_to_use": "Multiple product variants"
            },
            {
                "name": "Builder",
                "intent": "Construct complex objects step by step",
                "when_to_use": "Many configuration options"
            },
            {
                "name": "Prototype",
                "intent": "Create new objects by copying existing ones",
                "when_to_use": "Object creation is costly"
            },
            {
                "name": "Object Pool",
                "intent": "Reuse a set of expensive-to-create objects instead of creating and destroying them on demand",
                "when_to_use": "Database connections, threads and other costly resources"
            },
            {
                "name": "Lazy Initialization",
                "intent": "Delay creating an object or computing a value until it is first needed",
                "when_to_use": "Expensive objects that may never be used"
            },
            {
                "name": "Dependency Injection",
                "intent": "Supply an object's dependencies from outside instead of letting it construct them",
                "when_to_use": "Testing, configuration and swapping implementations without changing callers"
            }
        ]
    }
}
