convention-design-patterns

Implement eight design patterns with concrete Python examples.

Updated Mar 19, 2026
One-click install
npx skills add https://github.com/sunLeee/optimization --skill convention-design-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: convention-design-patterns
Source: https://github.com/sunLeee/optimization/tree/main/.claude/skills/reference/design-patterns
Command: npx skills add https://github.com/sunLeee/optimization --skill convention-design-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Design-pattern knowledge helps developers implement reusable, decoupled software architectures.

Core Features & Use Cases

  • Factory Pattern: decouples object creation from usage and centralizes creation logic.
  • Strategy Pattern: enables interchangeable algorithms at runtime without changing clients.
  • Repository Pattern: abstracts data access to promote testability and isolation.
  • Observer Pattern: supports event-driven communication between components.
  • Decorator Pattern: adds responsibilities dynamically without altering existing code.
  • Command Pattern: enables queuing, logging, and undo capabilities.
  • Adapter Pattern: bridges incompatible interfaces for seamless integration.
  • Template Method Pattern: defines the skeleton of an algorithm with customizable steps.

Quick Start

Study these patterns and implement Factory and Strategy in a sample module to observe how they improve structure.

Frequently Asked Questions about convention-design-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement the Factory pattern in Python to decouple object creation?

To implement the Factory pattern in Python, you centralize object creation logic in a separate class or method, decoupling the instantiation process from the client code that uses the objects. This promotes modular software architecture and reusable code.

When should I use the Strategy pattern for interchangeable algorithms?

Use the Strategy pattern when you need interchangeable algorithms at runtime without modifying the client logic. It defines a family of algorithms, encapsulates each one, and makes them interchangeable within your software architecture for flexible execution.

How does the Repository pattern abstract data access to improve testability?

The Repository pattern abstracts data access by mediating between the domain and data mapping layers. This isolation promotes testability by allowing you to mock data sources easily, ensuring your business logic remains independent of database implementation details.

What is the best way to bridge incompatible interfaces in Python?

The best way to bridge incompatible interfaces is the Adapter pattern, which wraps an existing class with a new interface so it can collaborate with other components. This enables robust integration across services without altering the original codebase.

Can I add responsibilities to objects dynamically without altering existing code?

Yes, you can add responsibilities dynamically using the Decorator pattern. It attaches additional behaviors to objects by placing them inside special wrapper classes, preventing the need to modify the existing structure of your software architecture.

Does the Command pattern support queuing and undo capabilities for user actions?

Yes, the Command pattern encapsulates a request as an object, which inherently supports queuing operations, logging requests, and implementing undo capabilities. This allows you to parameterize clients with different requests and manage execution flow.