# Clean Codejs Objects

> Object and class design patterns following Clean Code JavaScript.

- Skill: `damianwrooby/clean-codejs-objects` (Agent Skill)
- Install (CLI): `npx skillmds@latest add damianwrooby/clean-codejs-objects`
- Raw SKILL.md: https://api.skillmd.com/api/skills/damianwrooby/clean-codejs-objects/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: damianwrooby (https://skillmd.com/u/damianwrooby)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/damianwrooby/clean-codejs-objects

---


# Clean Code JavaScript – Object & Class Patterns

## Table of Contents
- Encapsulation
- Immutability
- Cohesion

## Encapsulation

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

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

## Immutability

```js
// ❌ Bad
user.age++;

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

## Cohesion

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

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

