clean-python-objects-data
Installation
SKILL.md
Clean Python 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
class Employee(Protocol):
def calculate_pay(self) -> Money:
...
@dataclass(frozen=True)
class SalariedEmployee:
salary: Money
def calculate_pay(self) -> Money:
return self.salary