本文へ移動
cccskills
無料GitHub で公開

design-patterns-pro

Apply classic design patterns judiciously: when each pattern fits, modern alternatives, and anti-patterns. Use when designing object interactions or reviewing pattern usage.

インストール方法を見る

含まれるファイル(1)

  • SKILL.md5.9 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Design Patterns Pro

Overview

Design patterns are a shared vocabulary for recurring design problems — not a checklist to apply. The professional skill isn't knowing 23 patterns; it's recognizing which problem you have, picking the simplest pattern that solves it, and knowing when modern language features made a pattern unnecessary.

The through-line: patterns serve the design — if you're contorting code to fit a pattern, you have it backwards.

When to use

  • Designing how objects collaborate in unfamiliar code.
  • Reviewing code for pattern misuse or over-engineering.
  • Naming a design ("this is basically Observer") to communicate it.
  • Refactoring toward a cleaner structure with a known shape.
  • Learning to see past pattern names to the underlying forces.

Core concepts

  • Patterns by purpose. Creational (how objects are made: Factory, Builder, Singleton — Singleton almost always wrong), Structural (how objects compose: Adapter, Decorator, Facade, Composite), Behavioral (how objects interact: Observer, Strategy, Command, State, Template Method). Classify the problem first; the pattern follows.
  • The essential dozen (modern take).
    • Strategy — interchangeable algorithms (sorting, pricing rules); often just functions/lambdas now.
    • Observer — subscribe/notify; language-level in reactive frameworks, event emitters elsewhere.
    • Decorator — layered behavior (middleware, Python decorators); prefer composition.
    • Adapter — translate interfaces at boundaries (anti-corruption layers).
    • Facade — simplify a subsystem's interface for common use.
    • Factory — when construction logic is non-trivial (parsing, DI containers); not for every new.
    • Builder — complex objects with many optional parts (fluent APIs, test fixtures).
    • Command — operations as objects (undo, queues, scheduling).
    • State — behavior varying by state; often replaceable by state machines or polymorphism.
    • Template Method — skeleton algorithm with hooks; often better as composition + strategy now.
    • Composite — tree structures treated uniformly (UI trees, file systems).
    • Repository — collection-like abstraction over persistence (a DDD staple).
  • Patterns dissolved by language features. Strategy → first-class functions; Observer → signals/reactive primitives; Singleton → DI containers or modules; Visitor → pattern matching; Iterator → for-of/generators. Modern languages absorbed many GoF patterns — use the feature, not the ceremony.
  • Composition over inheritance. The meta-pattern behind half the catalog: prefer composing small behaviors over deep hierarchies. Most pattern misuse is inheritance where composition fit.

Practical workflow

  1. Name the problem, not the pattern. "We need to swap pricing algorithms at runtime" — that's the requirement. Then notice it's Strategy-shaped.
  2. Start with the simplest thing. Functions before Strategy objects; a conditional before a State hierarchy; direct calls before Observer. Introduce the pattern at the second or third occurrence of the need.
  3. Apply minimally. Implement the pattern's essence, not its UML diagram. A Strategy can be a function parameter — it doesn't need an abstract class and three subclasses on day one.
  4. Check the modern alternative. Could a lambda, a match expression, or a framework primitive do this with less machinery? If yes, do that.
  5. Name it when you use it. If the design genuinely is Observer, say so in code/docs — the shared vocabulary is the point. Future readers pattern-match on names.
  6. Review for pattern abuse. AbstractFactoryFactory energy: patterns stacked on patterns, speculative generality ("we might need more strategies later"), and patterns applied where a plain function sufficed.

Pattern selection guide:

Varying algorithm at runtime      → Strategy (or just a function parameter)
Reacting to state changes         → Observer / signals / events
Adding behavior transparently     → Decorator (middleware, wrappers)
Incompatible interfaces           → Adapter (at system boundaries)
Complex construction              → Builder (many optionals) / Factory (non-trivial creation)
Undoable/queueable operations     → Command
Behavior depends on state         → State (or explicit state machine)
Tree structures                   → Composite
Simplifying a subsystem           → Facade

Common pitfalls

  • Pattern-first design. "Let's use Abstract Factory here" before understanding the problem. Patterns are solutions looking for problems — make sure you have the problem first.
  • Over-engineering via patterns. Full GoF ceremony for one variation that an if or function parameter would handle. YAGNI applies to patterns too.
  • Singleton abuse. Global mutable state with a fancy name — untestable, hidden coupling. DI, modules, or explicit parameters instead. (True singletons: rare — loggers, maybe.)
  • Inheritance-heavy patterns. Template Method hierarchies five deep, fragile base classes. Composition-based alternatives (strategy injection, hooks) are almost always more flexible.
  • Ignoring language features. Hand-rolled Observer with manual subscription lists in a signals-based framework; Visitor pattern where pattern matching exists. Use the language.
  • Pattern names as thought-terminating. "It's a Factory, don't question it" — the name should start the design conversation (does it fit? is it minimal?), not end it.
  • Not refactoring toward patterns. The flip side: duplicated conditionals that scream Strategy/State, left to rot because "patterns are over-engineering." Let the need emerge, then name and apply the pattern cleanly.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Master 1Password: vaults, Watchtower, passkeys, SSH agent, CLI, and family/team administration. Use when getting full value from 1Password personally or administering it for others.

日本語の概要は準備中です。原文の説明を表示しています。

aicodedecode/awesome-muse-skills132026年10月10日 更新

Create 3D visuals with modeling, texturing, lighting, rendering, and optimization for web and product.

日本語の概要は準備中です。原文の説明を表示しています。

aicodedecode/awesome-muse-skills132026年10月10日 更新

Create 3D web experiences: scene setup, models, materials, lighting, animation, scroll-driven scenes, and performance budgets. Use when adding 3D to websites beyond basic demos.

日本語の概要は準備中です。原文の説明を表示しています。

aicodedecode/awesome-muse-skills132026年10月10日 更新

Writing abstracts that get papers read — structured content, the 5-sentence core, and journal-specific constraints.

日本語の概要は準備中です。原文の説明を表示しています。

aicodedecode/awesome-muse-skills132026年10月10日 更新

Learn effectively from courses and academies: choosing programs, studying actively, and converting courses into skills. Use when investing time/money in structured learning.

日本語の概要は準備中です。原文の説明を表示しています。

aicodedecode/awesome-muse-skills132026年10月10日 更新

Audit designs for accessibility with WCAG checklists covering color, type, focus, motion, and content.

日本語の概要は準備中です。原文の説明を表示しています。

aicodedecode/awesome-muse-skills132026年10月10日 更新

aicodedecode のスキルをすべて見る

このスキルの問題を報告する