patterns

Recommend GoF design patterns for PHP and TypeScript code refactoring.

Updated Jun 19, 2023
One-click install
npx skills add https://github.com/JeroenJochems/modelwise --skill patterns-jeroenjochems
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: patterns
Source: https://github.com/JeroenJochems/modelwise/tree/main/.claude/skills/patterns
Command: npx skills add https://github.com/JeroenJochems/modelwise --skill patterns-jeroenjochems

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers identify and apply appropriate design patterns to recurring problems in software design, improving code structure, maintainability, and flexibility.

Core Features & Use Cases

  • Problem Identification: Analyzes code or design discussions to pinpoint situations where design patterns can offer solutions.
  • Pattern Recommendation: Suggests relevant GoF patterns based on identified design problems (e.g., object creation, behavior variation, structural composition).
  • Contextual Application: Provides guidance on mapping patterns to specific language idioms (PHP, TypeScript) and emphasizes using built-in language features when available.
  • Use Case: When refactoring a complex if-else structure based on object types, this Skill can recommend the Strategy pattern and guide its implementation.

Quick Start

Analyze the provided PHP code snippet and suggest an appropriate design pattern to simplify its structure.

Frequently Asked Questions about patterns

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

FAQPage Schema
How do I refactor complex if-else structures in TypeScript using design patterns?

To refactor complex if-else structures in TypeScript, apply the Strategy design pattern to encapsulate varying behavior, delegating object-type logic into separate interchangeable algorithm classes and improving code maintainability.

What is the best design pattern for object creation problems in PHP?

For object creation problems in PHP, the Factory pattern is often the best design pattern to use, centralizing instantiation logic and decoupling client code from specific class implementations.

When should I use the Decorator pattern instead of inheritance for structural composition?

Use the Decorator pattern for structural composition when you need to add responsibilities dynamically at runtime without modifying the underlying class, avoiding the rigid class hierarchy caused by static inheritance.

Can I use built-in language features instead of implementing GoF patterns in PHP and TypeScript?

Yes, you can and should use built-in PHP and TypeScript language features instead of strict GoF pattern implementations, mapping structural concepts to native idioms to prevent premature abstraction and reduce boilerplate.

How does the Facade pattern simplify structural composition in software architecture?

The Facade pattern simplifies structural composition in software architecture by providing a unified, simplified interface to a complex subsystem, hiding internal complexities and decoupling client code from underlying components.

Why does premature abstraction cause code quality issues when applying object-oriented design?

Premature abstraction degrades code quality when applying object-oriented design because it introduces unnecessary complexity and rigid structures before actual variation requirements emerge, making the codebase harder to maintain and refactor.