clean-typescript-objects-data
Installation
SKILL.md
Clean Objects And Data
Choose the shape that matches the job. Plain data is best for transfer, rendering, serialization, and pattern matching. Objects or classes are useful when behavior and invariants belong together.
OD1–OD2: Plain Data Versus Behavior
// Good - behavior belongs with the object
interface Employee {
calculatePay(): number;
}
class SalariedEmployee implements Employee {
constructor(private readonly salary: number) {}
calculatePay(): number {
return this.salary;
}
}