---
title: "Give each module one reason to change · Agent Wranglers"
url: https://agentwranglers.se/playbook/architecture/solid-and-dry/single-responsibility
updated: 2026-10-20
licence: "All rights reserved"
---

# Give each module one reason to change

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Required
- Chapter: [SOLID and DRY](https://agentwranglers.se/playbook/architecture/solid-and-dry)
- Rule: Each class, module or function serves one actor and has one reason to change.
- How: Name the person or team who would ask for a change. If a class answers to two, such as finance and the design team, split it. Keep calculation, storage and presentation apart.
- Check: In review, describe the module in one sentence without "and". A linter limit on file size flags likely offenders, such as ESLint `max-lines` at 300 or PHPMD `ExcessiveClassLength`.

Example:

```php
// Bad: pricing, storage and email in one class
class OrderService {
    public function place(Order $order): void { /* price, save, send email */ }
}

// Good: one reason to change each
final class OrderPricer { public function total(Order $order): Money { /* ... */ } }
final class OrderRepository { public function save(Order $order): void { /* ... */ } }
final class OrderMailer { public function sendConfirmation(Order $order): void { /* ... */ } }
```

```python
# Good: one reason to change each
class OrderPricer:
    def total(self, order: Order) -> Money: ...

class OrderRepository:
    def save(self, order: Order) -> None: ...

class OrderMailer:
    def send_confirmation(self, order: Order) -> None: ...
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers architecture playbook: https://agentwranglers.se/playbook/architecture/solid-and-dry/single-responsibility`.

- Previous: [Keep each piece of knowledge in one place](https://agentwranglers.se/playbook/architecture/solid-and-dry/dry)
- Next: [Extend code without editing it](https://agentwranglers.se/playbook/architecture/solid-and-dry/open-closed)
- [SOLID and DRY](https://agentwranglers.se/playbook/architecture/solid-and-dry)
