johnnystefan/test-saas-business/factory-method

Claude Code and agent skill by johnnystefan/test-saas-business

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Teaches and applies the Factory Method creational design pattern — providing an interface for creating objects in a superclass, allowing subclasses to decide which class to instantiate. Trigger: When decoupling object creation from usage or implementing extensible creation logic.

Install

npx vskill@latest install johnnystefan/test-saas-business/factory-method

SKILL.md

The same SKILL.md was published earlier as johnnystefan/test-saas-business/factory-method.

Skill: Implement Factory Method Pattern

Purpose

Provides an interface for creating objects in a superclass but allows subclasses to alter the type of objects that will be created. It decouples the business logic from the concrete classes it needs to instantiate.

Procedural Instructions

  1. Identify Direct Instantiation: Look for new ConcreteClass() calls that make the code rigid.
  2. Define Product Interface: Ensure all products follow a common interface.
  3. Create Creator Class: Declare the factory method. It should return the product interface.
  4. Implement Subclasses: Create concrete creators that override the factory method to return specific instances of products.

TypeScript Example

typescript
// Product Interface
interface Transport {
deliver(): string;
}
// Concrete Products
class Truck implements Transport {
deliver() {
return 'Delivering by land in a box.';
}
}
class Ship implements Transport {
deliver() {
return 'Delivering by sea in a container.';
}
}
// Creator Class
abstract class Logistics {
public abstract createTransport(): Transport;
public planDelivery(): string {
const transport = this.createTransport();
return transport.deliver();
}
}
// Concrete Creators
class RoadLogistics extends Logistics {
public createTransport(): Transport {
return new Truck();
}
}
class SeaLogistics extends Logistics {
public createTransport(): Transport {
return new Ship();
}
}

Payoff

  • OCP Compliance: You can introduce new types of products without breaking existing client code.
  • SRP Compliance: Product creation code is localized in one place.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/johnnystefan/test-saas-business/factory-method/badge)](https://verified-skill.com/skills/johnnystefan/test-saas-business/factory-method)

Something wrong with this skill or its page? Tell us.