Skip to content

FunctionalCoreImperativeShell

Dennis Lee edited this page May 27, 2026 · 1 revision

title: Functional Core, Imperative Shell radar_quadrant: Techniques radar_ring: Assess radar_position: inner

Functional Core, Imperative Shell

Functional Core, Imperative Shell is an architectural pattern that separates application logic from side effects. The "functional core" consists of pure functions — calculations, decisions, transformations — that take inputs and return outputs with no external dependencies. The "imperative shell" is a thin outer layer that handles all side effects: IO, database calls, API calls, and UI. The core is dependency-free and trivially unit-testable; the shell is thin enough to be obviously correct. The pattern was introduced by Gary Bernhardt in his talk "Boundaries" and has been endorsed by Google's Testing Blog.

Radar Assessment

Most code that is hard to test is hard to test because it mixes logic with side effects: a single function that calculates a result, writes it to a database, and sends a notification. Disentangling these concerns retroactively is expensive. Functional Core, Imperative Shell establishes the separation as a first-class architectural decision: all logic lives in the core, all effects live in the shell. The core is tested exhaustively with unit tests; the shell is kept so thin that it requires minimal testing.

Placed in Assess at inner position because the pattern is language-agnostic, broadly applicable, and directly improves testability without requiring a new framework or toolchain. Google's Testing Blog endorsement signals it is moving from expert knowledge to mainstream practice. The inner position reflects that developers should be actively evaluating this pattern for new codebases and refactoring candidates rather than waiting for further validation.

The pattern is complementary to hexagonal architecture and ports-and-adapters; it focuses specifically on the logic/effects boundary rather than the broader dependency inversion concern.

Clone this wiki locally