danielpohlmann/ia-marktplace/dev-design-patterns-creational

Claude Code and agent skill by danielpohlmann/ia-marktplace

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Use when implementing a GoF creational pattern: Factory Method, Abstract Factory, Builder, Prototype, Singleton. USE FOR: decoupling instantiation, fluent builders, cloning, controlled single instances. DO NOT USE FOR: composing/adapting objects (use dev-design-patterns-structural), communication and algorithms (use dev-design-patterns-behavioral), picking a family (use dev-design-patterns).

Install

npx vskill@latest install danielpohlmann/ia-marktplace/dev-design-patterns-creational

SKILL.md

The same SKILL.md was published earlier as danielpohlmann/ia-marktplace/dev-design-patterns-creational.

Creational Design Patterns

Overview

Creational patterns abstract the instantiation process. They help make a system independent of how its objects are created, composed, and represented. As systems evolve to depend more on object composition than class inheritance, the emphasis shifts from hard-coding fixed sets of behaviors toward defining a smaller set of fundamental behaviors that can be composed into more complex ones — and that requires flexible object creation.

Full per-pattern implementations, structure, code examples, and trade-offs live in [references/patterns.md](references/patterns.md) (see the Detailed reference table). The tables and decision guide below are enough to choose one and to review code.

Comparison Table

PatternScopeKey BenefitTypical Use Case
Factory MethodClassDefers creation to subclassesFrameworks that define interfaces but let apps decide implementations
Abstract FactoryObjectCreates families of related objectsCross-platform UI toolkits, themed component libraries
BuilderObjectStep-by-step construction with fluent APIComplex objects with many optional parameters (HTTP requests, queries)
PrototypeObjectCloning pre-configured instancesGame units, document templates, expensive-to-create objects
SingletonObjectGuarantees single instanceConfiguration, connection pools (prefer DI singleton lifetime)
Simple Factory (not GoF)ObjectOne place owns a creation conditionalPick an implementation from a type code, config value or request field

Simple Factory is an idiom, not one of the GoF patterns: a single method that holds the if/switch choosing which class to instantiate. It does not remove the Open/Closed violation — adding a variant still means editing the switch — it deliberately concentrates that violation in one place instead of letting it spread across call sites.

Decision Guide

Do you need to create objects?
│
├─ One product, varies by subclass?
│ └─▶ Factory Method
│
├─ Families of related products?
│ └─▶ Abstract Factory
│
├─ Complex object with many parts/options?
│ └─▶ Builder
│
├─ Copy an existing configured object?
│ └─▶ Prototype
│
├─ Exactly one instance, globally accessible?
│ └─▶ Singleton (but strongly consider DI singleton lifetime instead)
│
└─ Same "which class do I create?" conditional repeated in many places?
└─▶ Simple Factory (injectable), or a registry keyed by type code

Review Signals

Use this table during code review: the left column is what suggests the pattern is missing, the right column is what suggests it is misapplied.

PatternSignals in code (pattern is needed)When NOT to use (anti-signals / overuse)
Simple FactoryThe same creation if/switch copied into several endpoints, handlers or jobs; each new variant requires a multi-file huntOnly one call site creates the object; only one implementation exists. A static factory method is itself a smell — callers cannot substitute it in tests. Prefer an injectable factory interface or a registry (Dictionary<key, Func<T>>, keyed DI services)
Factory MethodA base class/framework hard-codes new ConcreteX() that subclasses or plugins need to changeA subclass hierarchy created only to vary one constructor call — pass a factory delegate or use DI instead
Abstract FactoryCode mixes products from different families (e.g. a light-theme button with a dark-theme dialog); conditionals on the "family" repeated per productOnly one family exists or products are unrelated; adding a product type forces edits to every factory — accept that cost only if families are stable
BuilderTelescoping constructors, many optional/boolean parameters, objects observable in a half-initialized state, the same multi-line setup copied in testsFew required fields — a constructor, object initializer or record with named/default arguments is clearer; a builder that does no validation adds ceremony only
PrototypeExpensive setup repeated to produce near-identical objects; copy code that reads every field by handObjects are cheap to build; deep graphs with shared references or external handles where clone semantics (shallow vs deep) are ambiguous
SingletonHand-rolled static Instance / getInstance(); mutable global state; tests that pass alone but fail depending on execution order; hidden dependencies not declared in constructorsAlmost always prefer a DI singleton lifetime. Never for state that differs per request, tenant or user
Singleton thread-safety

Hand-written lazy initialization (if (instance == null) instance = new X();) is not thread-safe: two threads can both pass the null check and create two instances, each holding different state (a check-then-create race). Ad-hoc double-checked locking is easy to get wrong. In .NET:

  • Register the service with a singleton lifetime in the DI container (services.AddSingleton<IX, X>()) — the container guarantees one instance and keeps the dependency visible in constructors.
  • When no container is available, use `Lazy<T>` (thread-safe by default) or a static readonly field initialized by the type initializer.
  • Keep the instance immutable or internally synchronized; a singleton shared across threads is shared mutable state.

Detailed reference

FileContents
references/patterns.mdFactory Method, Abstract Factory, Builder, Prototype, Singleton, Simple Factory — intent, structure, participants, when to use, TypeScript examples

References

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/danielpohlmann/ia-marktplace/dev-design-patterns-creational/badge)](https://verified-skill.com/skills/danielpohlmann/ia-marktplace/dev-design-patterns-creational)

Something wrong with this skill or its page? Tell us.