Separation of concerns assigns distinct responsibilities to separate components. Give each package or structure a role that can be described in one sentence, while recognizing that excessive separation can create costly coupling. section 8.3
Apply the principle by:
- Separating data fetching from data use so external-service logic can change without touching money conversion. section 6.5
- Providing dependencies through contracts such as interfaces, allowing stubs during development and replacements such as caches later. section 6.5
- Isolating storage management from API details, while accepting that some performance requirements may require them to evolve together. section 8.3
Splitting a Gordle service
Keep the session responsible for IDs, attempts, feedback history, and attempt limits. Keep the Gordle package responsible for creating games, evaluating guesses, and reporting whether a game is over. section 8.5
Table 8.2 Package requirements
| Package session’s game |
Package Gordle’s game |
|
|
Use the responsibility table to decide which state and behavior belong in the session or Gordle package. section 8.5





















