- Home
- Skills
- Bfmcneill
- Agi Marketplace
- Design Patterns
design-patterns_skill
0
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill bfmcneill/agi-marketplace --skill design-patterns- SKILL.md4.0 KB
Overview
This skill helps developers apply classic object-oriented design patterns when refactoring or designing flexible systems. It covers creational, structural, and behavioral patterns with practical Python-driven guidance and selection advice. Use it to choose patterns that reduce coupling, clarify responsibilities, and make systems easier to extend and test.
How this skill works
The skill explains when each pattern is appropriate, outlines trade-offs, and maps common anti-patterns to pattern-based fixes. It includes quick-reference comparisons of complexity and typical use cases, plus Python examples for Factory, Builder, Decorator, Observer, Strategy, Command, State, Adapter, Facade, Proxy, and Singleton. Follow the pattern selection guide to match a concrete problem (large constructors, conditional logic, notification needs) to the pattern that simplifies the design.
When to use it
- Refactoring code with deep conditionals, duplicated variants, or tangled responsibilities
- Designing systems that must stay flexible for changing requirements
- Replacing hardcoded dependencies or large constructors with clearer creation strategies
- Simplifying complex libraries or subsystems behind a concise API
- Implementing runtime algorithm switching, event notification, or undo/redo behavior
Best practices
- Prefer the simplest pattern that addresses the problem; avoid premature abstraction
- Favor composition over inheritance and program to interfaces or abstract types
- Document why a pattern was chosen and the trade-offs it introduces
- Introduce patterns incrementally during refactoring rather than all at once
- Use tests to validate behavior before and after applying a pattern to prevent regressions
Example use cases
- Replace a long constructor with a Builder to handle many optional parameters cleanly
- Swap a large switch-case for Strategy or State to make algorithms pluggable and testable
- Wrap a third-party library with a Facade to expose a simpler, stable API
- Use Observer to notify multiple UI components of model changes without tight coupling
- Apply Decorator to add features (logging, caching) to objects at runtime without modifying their code
FAQ
Use Singleton sparingly for truly global, shared resources (configuration, connection pools); prefer dependency injection for testability and explicit dependencies.
How do I avoid over-engineering with patterns?
Start with the simplest working solution, add patterns only when you see maintenance pain, duplication, or rigidity that the pattern directly solves.