skills/skills.volces.com/strategy-pattern-implementor

strategy-pattern-implementor

Installation
SKILL.md

Strategy Pattern Implementor

When to Use

You have a class that selects between algorithm variants and need to refactor it so algorithms can vary independently from the clients that use them. This skill applies when:

  • A class contains switch statements or if/else chains that select between behavioral variants — the primary code smell
  • Multiple related classes differ only in their behavior (same structure, different computation)
  • You need different space-time trade-offs for the same operation (fast-and-approximate vs. slow-and-precise)
  • An algorithm uses data clients should not know about (complex internal data structures that would leak through the interface)
  • You need to swap the algorithm at runtime without changing the client

Before starting, confirm:

  • Is this a client-selected algorithm switch (Strategy) rather than an object self-transitioning based on internal state (State)? If unsure, use behavioral-pattern-selector first.
  • Does the variation belong in the class itself, or is it better expressed via a superclass skeleton with subclass steps (Template Method via inheritance)? Strategy uses composition — the algorithm is a separate object, not a subclass.

Process

Installs
3
First Seen
Apr 24, 2026
strategy-pattern-implementor from skills.volces.com