An imperative shell isolates side effects and nondeterministic interactions around a deterministic functional core. Dependency arrows point outward: the core computes from supplied data, while the shell reads services, time, files, and APIs. section 6.2 section 10.4.3
Separate responsibilities by asking what each operation depends on:
- Keep parsing, data construction, and business rules in deterministic functions that accept inputs and return outputs. section 10.4.3
- Place database reads, cloud storage, clocks, random values, and external service calls in the imperative shell. section 6.2
- Test the core with ordinary inputs and outputs, reserving mocks and integration setup for the shell boundary. section 11.2
Refactoring a cloud-backed repository
Instead of making loadAccounts download bytes, parse CSV, and construct Accounts in one method, let the shell read the resource and delegate parsing: return FileRepository.parse(this.read(resource)). The static parse method then transforms bytes into Account values without knowing about CloudStore. Its test supplies CSV bytes directly and asserts the resulting collection, avoiding cloud mocks and setup.
