What problem does it solve?
This Skill provides a framework to help developers make informed decisions about whether to refactor duplicated code into a shared abstraction or to keep them separate, preventing premature or incorrect abstractions.
Core Features & Use Cases
- Decision Framework: Offers a structured checklist to guide the abstraction decision.
- DRY Principle Clarification: Emphasizes that DRY applies to knowledge, not just syntax.
- Rule of Three Guidance: Recommends abstracting only after encountering three or more instances.
- Cost-Benefit Analysis: Helps evaluate the true cost of an abstraction versus the cost of duplication.
- Code-Generated Types Handling: Provides strategies for dealing with similar types generated by different tools.
- Anti-Corruption Layer Considerations: Addresses abstraction in the context of Domain-Driven Design.
- Use Case: When you have three similar API client adapters, this skill helps you determine if they should be unified under a single interface or kept separate.
Quick Start
Use the duplication-vs-abstraction skill to decide if the three similar code snippets should be refactored into a single abstraction.