スキル一覧に戻る
lucianoMintrone

oop-specialist

by lucianoMintrone

0🍴 0📅 2026年1月23日
GitHubで見るManusで実行

SKILL.md


name: oop-specialist description: Apply object-oriented design principles (SOLID/GRASP) when writing or reviewing code in this TypeScript + Next.js codebase. Use when designing/refactoring services, libraries, domain models, and module boundaries; triggers on high coupling, low cohesion, duplicated business rules, and unclear responsibilities.

OOP Specialist

Apply these principles when designing, writing, or reviewing object-oriented code.

Core Constraints (Heuristics)

  • Keep methods small and intention-revealing (extract aggressively)
  • Keep classes/modules focused (one reason to change)
  • Prefer parameter objects over long parameter lists

SOLID Principles

PrincipleRuleViolation Sign
SRPOne reason to changeClass name includes "And" or "Manager"
OCPExtend, don't modifyAdding features requires changing existing code
LSPSubtypes substitute baseOverridden method raises unexpected errors
ISPSmall, specific interfacesImplementing empty/stub methods
DIPDepend on abstractionsInstantiating dependencies directly

GRASP Principles

  • Information Expert: Assign responsibility to class with the data
  • Creator: Create objects where they're contained/aggregated/used
  • Low Coupling: Minimize dependencies between classes
  • High Cohesion: Keep class responsibilities focused
  • Controller: Delegate UI events to controller, not domain objects
  • Polymorphism: Replace conditionals on type with polymorphic methods
  • Pure Fabrication: Create utility classes when no domain class fits
  • Protected Variations: Hide change-prone areas behind interfaces

Key Heuristics

Tell, Don't Ask

// Bad: pull data out, decide elsewhere
if (order.status === "pending" && order.totalCents > 10_000) {
  order.applyDiscountPercent(10);
}

// Good: tell the object what to do
order.applyDiscountIfEligible();

Composition Over Inheritance

Use inheritance only when child "is-a" parent. Prefer composition for "has-a" or "uses-a" relationships.

type Item = { id: string; priceCents: number };
type PricingStrategy = { priceTotalCents: (items: Item[]) => number };

class Order {
  constructor(private readonly pricingStrategy: PricingStrategy) {}

  totalCents(items: Item[]) {
    return this.pricingStrategy.priceTotalCents(items);
  }
}

DRY (Don't Repeat Yourself)

Extract duplicated logic. Three occurrences = extract immediately.

Design Patterns Quick Reference

PatternUse When
FactoryObject creation logic is complex or varies
BuilderConstructing complex objects step-by-step
StrategyAlgorithms vary and should be interchangeable
StateBehavior changes based on internal state
FacadeSimplifying a complex subsystem interface
Template MethodAlgorithm structure fixed, steps vary
Null ObjectAvoiding nil checks with default behavior

Functional Patterns

Prefer map, filter/select, reduce over manual iteration:

// Bad
const results: string[] = [];
for (const item of items) {
  if (item.active) results.push(item.name);
}

// Good
const results = items.filter((i) => i.active).map((i) => i.name);

Clean Architecture Layers

┌─────────────────────────────────────┐
│  Frameworks & Drivers (outer)       │  ← Next.js, React, Prisma/Postgres
├─────────────────────────────────────┤
│  Interface Adapters                 │  ← Controllers, Serializers
├─────────────────────────────────────┤
│  Use Cases                          │  ← Service Objects
├─────────────────────────────────────┤
│  Entities (inner)                   │  ← Domain Models
└─────────────────────────────────────┘

Dependencies point INWARD only.

In this repo, a practical mapping is:

  • Frameworks & drivers: Next.js App Router, NextAuth, Prisma, Postgres
  • Interface adapters: src/app/* pages, route handlers, server actions
  • Use cases: src/services/* (business rules)
  • Entities: Prisma models + domain types

References

For detailed patterns and examples:

スコア

総合スコア

50/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です