clean-codejs-objects

📁 damianwrooby/javascript-clean-code-skills 📅 6 days ago
1
总安装量
1
周安装量
#43263
全站排名
安装命令
npx skills add https://github.com/damianwrooby/javascript-clean-code-skills --skill clean-codejs-objects

Agent 安装分布

amp 1
opencode 1
kimi-cli 1
github-copilot 1
claude-code 1

Skill 文档

Clean Code JavaScript – Object & Class Patterns

Table of Contents

  • Encapsulation
  • Immutability
  • Cohesion

Encapsulation

// ❌ Bad
user.name = 'John';

// ✅ Good
user.rename('John');

Immutability

// ❌ Bad
user.age++;

// ✅ Good
const updatedUser = user.withAge(user.age + 1);

Cohesion

// ❌ Bad
class User {
  calculateTax() {}
}

// ✅ Good
class TaxCalculator {
  calculate(user) {}
}