Skip to content
Agentmart
Submit a tool

code-smells/oo-abusers

Detect and refactor OO Abusers — incorrect or incomplete application of OOP principles.

Skill by gentleman-programming

IndexedApache-2.0
Write a review

Install

Works with Claude Code. Read the repository before you give any tool access to your data.

npx agentmarket install skill/johnnystefan-code-smells-oo-abusers

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Detect and refactor OO Abusers — incorrect or incomplete application of OOP principles. Trigger: When identifying Switch Statements, Temporary Fields, Refused Bequest, or Alternative Classes with Different Interfaces.

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/code-smells-oo-abusers

Tools it pre-approves 7

From allowed-tools in SKILL.md: the agent may use these without asking you each time.

  • Read,
  • Edit,
  • Write,
  • Glob,
  • Grep,
  • Bash,
  • Task

What's inside

Skill name
code-smells/oo-abusers
Description
Detect and refactor OO Abusers — incorrect or incomplete application of OOP principles. Trigger: When identifying Switch Statements, Temporary Fields, Refused Bequest, or Alternative Classes with Different Interfaces.
License
Apache-2.0
Allowed tools
Read,, Edit,, Write,, Glob,, Grep,, Bash,, Task
Metadata
author: gentleman-programming · version: 1.0 · auto_invoke: Reviewing OOP design and polymorphism usage
Instructions
104 lines in SKILL.md · view on GitHub

Before installing

  • Pre-approves some shell commands

Agent Skills spec issues

  • name: only lowercase letters, digits and single hyphens allowed
  • name: "code-smells/oo-abusers" does not match folder "oo-abusers"

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Skill: Detect and Refactor Object-Orientation Abusers

## Purpose

This skill enables the agent to identify "OO Abusers" — code structures that result from an incomplete or incorrect application of object-oriented programming principles. The agent will replace these structures with proper polymorphic behavior and cleaner class hierarchies.

## Domain Knowledge: The 4 OO Abusers

1. **Switch Statements:** Complex `switch` operators or sequences of `if` statements that perform different actions based on an object's type or state.
2. **Temporary Field:** Fields that only get values under certain specific circumstances, remaining empty or `null` otherwise.
3. **Refused Bequest:** A subclass that uses only a small portion of the methods and properties inherited from its parent. The hierarchy is "off-kilter."
4. **Alternative Classes with Different Interfaces:** Two classes that perform identical or very similar functions but have different method names.

## Procedural Instructions

### 1. Detection Phase

- **Identify Switch logic:** Look for methods where behavior is branched based on a `type` code or class name.
- **Audit Field Usage:** Check if certain fields in a class are only used by one specific method and otherwise ignored.
- **Review Inheritance:** Check if a subclass throws "Not Supported" exceptions for inherited methods or simply leaves them empty.
- **Compare Classes:** Look for different classes that seem to do the same work but use different naming conventions (e.g., `getTotal()` vs `calculateSum()`).

### 2. Treatment Phase

- **For Switch Statements:**
  - Use **Extract Method** to isolate the switch.
  - Use **Move Method** to put it in the right class.
  - Apply **Replace Conditional with Polymorphism**.
- **For Temporary Fields:**
  - Use **Extract Class** to create a separate object for the fields and the operations that use them.
  - Use **Introduce Null Object** to eliminate conditional checks for the field's existence.
- **For Refused Bequest:**
  - If inheritance makes no sense, use **Replace Inheritance with Delegation**.
  - If inheritance is appropriate but the parent is too fat, use **Extract Superclass** to pull up only the common parts.
- **For Alternative Classes:**
  - Use **Rename Method** to align signatures.
  - Use **Move Method** or **Extract Superclass** to merge the functionalities.

## TypeScript Examples

### Switch Statements vs. Polymorphism

```typescript
// BAD: Switch statement based on type
class Bird {
  getSpeed(type: string) {
    switch (type) {
      case 'EUROPEAN':
        return 10;
      case 'AFRICAN':
        return 15;
      default:
        return 0;
    }
  }
}

// GOOD: Replace with Polymorphism
interface Bird {
  getSpeed(): number;
}

class European implements Bird {
  getSpeed() {
    return 10;
  }
}

class African implements Bird {
  getSpeed() {
    return 15;
  }
}
```

### Refused Bequest

```typescript
// BAD: A Chair is not an Animal, even if they both have legs
class Animal {
  eat() {
    console.log('Eating...');
  }
}

class Chair extends Animal {
  eat() {
    throw new Error("Chairs don't eat!");
  } // Refused Bequest
}

// GOOD: No false "is-a" relationship
class Chair {
  legs: number = 4;
}
```

## Payoff

- **Flexibility:** Adding a new type no longer requires finding and changing every switch statement in the codebase.
- **Code Clarity:** Classes no longer contain "ghost" fields that are only used 1% of the time.
- **Logical Hierarchies:** Inheritance trees represent real "is-a" relationships, making the code predictable.

From johnnystefan/test-saas-business, Apache-2.0.

More from johnnystefan/test-saas-business

Signals

Stars
0
Forks
0
Open issues
0
Last commit (this folder)
Apr 1, 2026 (7 months ago)

From GitHub (fetched Oct 24, 2026).

Details

Version
1.0
License
Apache-2.0
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from gentleman-programming

Cite this page

code-smells/oo-abusers skill. Agent Mart. https://agentmart.dev/skills/johnnystefan-code-smells-oo-abusers (last updated 2026-10-24)